Why does this statement don't work at all? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Why does this statement don't work at all?

age=14 if("age>=15") print("old") else: if("age<=14") print("shit") if i change age i expected the print out to change according to the command but dnt know y

10th May 2018, 5:53 AM
Abdi Aziz Mohamed
Abdi Aziz Mohamed - avatar
3 Respostas
+ 12
Nimcan I suggest going through the Python course one lesson at a time and you will surely learn how to write code that works. In your code (it's a good first try!): The first 'if' statement - doesn't need parentheses - shouldn't have quotes around the expression - must have a colon at the end The first print() function - must be indented The second 'if' statement - doesn't need parentheses - shouldn't have quotes around the expression - must have a colon at the end - is actually unnecessary The second print() function - must be indented - makes you wonder if crude language is really necessary.... This works: age = 14 if age >= 15: print("old") else: print("yikes") Next time you need help with your code, I suggest saving it in the Code Playground and then sharing a link here so we can try it out to see the error messages. Keep on coding! šŸ˜Ž
10th May 2018, 6:19 AM
David Ashton
David Ashton - avatar
+ 3
Don't put the age>=15 and the age<=14 in quotation marks, as it is not supposed to be a string, or is it?
10th May 2018, 9:23 AM
Paul Grasser
Paul Grasser - avatar
+ 2
thanks gyz hv understand know y it didnt work
10th May 2018, 5:52 PM
Abdi Aziz Mohamed
Abdi Aziz Mohamed - avatar