+ 1
Hi
I wanted to understand what is wrong with this code import random color = ['red','orange','yellow','green','blue','purple'] print(random.choice(color)) x = str(input("Do you want to see the color ?? \t y/n \t") print(x) if x == "y": it says invalid syntax with the print in "print(x)"
5 Respostas
+ 2
#Hi
#I wanted to understand what is wrong with this code
import random
color = ['red','orange','yellow','green','blue','purple']
print(random.choice(color))
x = str(input("Do you want to see the color ?? \t y/n \t"))
print(x)
#if x == "y":
#it says invalid syntax with the print in "print(x)"
+ 2
import random
color = ['red','orange','yellow','green','blue','purple']
print(random.choice(color))
x = input("Do you want to see the color ?? \t y/n \t")
#You have missed one bracket
print(x)
if x == "y":
print("print something if u value is Y ")
#you have given if statement
https://code.sololearn.com/c9DlFdProXZb/?ref=app
+ 2
greendragon4221 The str() cast isn't necessary, as the input is always in the string form.
0
Check the brackets for input statement
0
thanks guys
i fixed it
😃😃