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]
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)
+ 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.
+ 2
Ok, Glory Isah
+ 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.
+ 1
Yeah😄
thank you...I learnt it.🤗
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 😁.