+ 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)"

3rd Aug 2021, 3:32 AM
greendragon4221
greendragon4221 - avatar
5 ответов
+ 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)"
3rd Aug 2021, 4:04 AM
Atul [Inactive]
+ 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
3rd Aug 2021, 4:10 AM
Pariket Thakur
Pariket Thakur - avatar
+ 2
greendragon4221 The str() cast isn't necessary, as the input is always in the string form.
3rd Aug 2021, 5:30 AM
Calvin Thomas
Calvin Thomas - avatar
0
Check the brackets for input statement
3rd Aug 2021, 4:05 AM
Atul [Inactive]
0
thanks guys i fixed it 😃😃
3rd Aug 2021, 4:52 AM
greendragon4221
greendragon4221 - avatar