0

Hi guys been having problem with the if state code on pydroid app...

age =70 if age <=18 & age<=45 print("you are welcome to the party") elif age>45: print("you are very welcom") else: print("go home") print(20). THIS IS THE ERROR MESSAGE. Traceback (most recent call last): File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module> start(fakepyfile,mainpyfile) File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), __main__.__dict__) File "<string>", line 3 if age <=18 & age<=45 ^ SyntaxError: invalid syntax [Program finished]

15th Dec 2021, 9:01 PM
Glory Isah
6 Antworten
+ 6
You need to include colon after the first if block once placing that and fixing the indention in proper way it won't give any error. Below is the fixed code attached age =70 if age <=18 & age<=45: print("you are welcome to the party") elif age>45: print("you are very welcom") else: print("go home") print(20)
15th Dec 2021, 9:20 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 3
Hello, Glory Isah! You miss the ":" symbol and you miss the logic operator "and". And your identation in the print(20) is very much. Your error is in "&" because that symbol is a byte operator.
15th Dec 2021, 9:42 PM
CGO!
CGO! - avatar
+ 2
16th Dec 2021, 12:22 PM
CGO!
CGO! - avatar
+ 1
Glory Isah I was telling you that! But I'm not going to write the code for you! You have to learn, that's the point of this, no offense.
16th Dec 2021, 1:16 AM
CGO!
CGO! - avatar
+ 1
Yeah😄 thank you...I learnt it.🤗
16th Dec 2021, 6:52 AM
Glory Isah
0
Thank you so much guys your response where helpful..after trying all the suggestions and it didn't work,I had to use another App(Code Editor). Used colon and changed the & to and,< to > in the line 3. age >=18 and age <=45: You will see more of me here o😄😄..I am a beginner 😁.
16th Dec 2021, 12:11 AM
Glory Isah