+ 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"
12 Réponses
+ 7
Take out the equals sign after print and give it another try
print(1)
+ 4
Also: print=“error” should be print(“error”)
+ 2
Better to use dictionary.
d = {
'red':1,
'green':2,
'black':3
}
color = input()
if color in d:
print(d[color])
else:
print('error')
+ 1
OK bro
+ 1
Not working ravilnicki
+ 1
Sure
+ 1
Thanks your code is working Brave Tea
+ 1
My pleasure!
+ 1
Ya
+ 1
Code is working broos
0
Your brackets on error
- 1
Try using the double quotes in print . For example :
print("1")