+ 1

Can any one check my code?

color=input() if color == 'red': print=(1) elif color =='green': print=(2) elif color =='black': print =(3) else: print="error"

9th Mar 2022, 8:02 AM
Arunesh Kishore
12 odpowiedzi
+ 7
Take out the equals sign after print and give it another try print(1)
9th Mar 2022, 8:03 AM
Brave Tea
Brave Tea - avatar
+ 4
Also: print=“error” should be print(“error”)
9th Mar 2022, 8:07 AM
Brave Tea
Brave Tea - avatar
+ 2
Better to use dictionary. d = { 'red':1, 'green':2, 'black':3 } color = input() if color in d: print(d[color]) else: print('error')
9th Mar 2022, 1:36 PM
Shadoff
Shadoff - avatar
+ 1
OK bro
9th Mar 2022, 8:04 AM
Arunesh Kishore
+ 1
Not working ravilnicki
9th Mar 2022, 8:06 AM
Arunesh Kishore
+ 1
Sure
9th Mar 2022, 8:07 AM
Arunesh Kishore
+ 1
Thanks your code is working Brave Tea
9th Mar 2022, 8:08 AM
Arunesh Kishore
+ 1
My pleasure!
9th Mar 2022, 8:09 AM
Brave Tea
Brave Tea - avatar
+ 1
Ya
9th Mar 2022, 8:09 AM
Arunesh Kishore
+ 1
Code is working broos
10th Mar 2022, 9:25 PM
Ricky Ameer
Ricky Ameer - avatar
0
Your brackets on error
10th Mar 2022, 7:48 PM
Ethan Sunker
Ethan Sunker - avatar
- 1
Try using the double quotes in print . For example : print("1")
10th Mar 2022, 11:26 PM
Programer F_K
Programer F_K - avatar