Can you guys help me Im trying to code something and it's a error and thank you | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can you guys help me Im trying to code something and it's a error and thank you

num = zero if input() = 1: num = one print(num)

1st Dec 2021, 2:27 AM
HELP MEl
10 Answers
+ 4
Also: input returns a string, so the condition in your if statement will always be False.
1st Dec 2021, 2:45 AM
Simon Sauter
Simon Sauter - avatar
+ 5
num = "zero" if input() == "1": num = "one" print(num)
1st Dec 2021, 3:03 AM
Simon Sauter
Simon Sauter - avatar
+ 1
Can you send fixed code please? https://code.sololearn.com/cG63Ei2whqB6/?ref=app
1st Dec 2021, 2:53 AM
HELP MEl
+ 1
Hello, HELP MEl! Of course you have a error, in num = zero have be num = "zero" and in num = one is num = "one". Because there are not variable/function with that name. Simon Sauter You're right, is as I say.
2nd Dec 2021, 1:13 AM
CGO!
CGO! - avatar
0
In the if statement you have to use the comparison operator "==", not the assignment operator "=".
1st Dec 2021, 2:43 AM
Simon Sauter
Simon Sauter - avatar
0
Oh yeah..
1st Dec 2021, 2:44 AM
HELP MEl
0
Use 0 and "1" instead of zero and one. Because the latter ones are identifiers
1st Dec 2021, 2:45 AM
Carlos
Carlos - avatar
0
Or use quotation marks if you want to use strings.
1st Dec 2021, 2:46 AM
Simon Sauter
Simon Sauter - avatar
0
I'm trying to do a project that turns numbers to word numbers aka 1 - one
1st Dec 2021, 2:47 AM
HELP MEl
- 4
puthon
2nd Dec 2021, 7:56 PM
ABDÜLKADİR NANİŞ