Python Forum
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Qpython3 error
#1
Hey guys, I'm trying out an app for Android called Qpython3, which is pretty cool so far. I'm a beginner to intermediate in python, and I want to be able to practice on the go. I don't find anything wrong with my code, but it's coming up with an error on the while loop at the end. I don't know if it's the app, or just my fault. Any help would be appreciated!

# Set base control variable
control = "control"

print("")
print("a: New Game")
print("b: Load Game")
print("")
print("quit: available at any time.")
print("")


def main():
    control = input(str(">> ")
    	
# Main loop
while control != "quit":
    main()
Reply
#2
what error do you get? Post full traceback in error tags. Note that there is missing closing parenthesis on line 13. Also note that control within the main function (i.e. line 13)is different variable from the one on line 2 and line 16, i.e. after you fix the problem, you will be in infinite loop
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Dec-03-2018, 07:34 AM)buran Wrote: what error do you get? Post full traceback in error tags. Note that there is missing closing parenthesis on line 13. Also note that control within the main function (i.e. line 13)is different variable from the one on line 2 and line 16, i.e. after you fix the problem, you will be in infinite loop

I get a SyntaxError on line 16. I didn't notice the closing parentheses, and that must have been the problem! And for the variables, that would fix another problem. Thank you for the help! My goal is to create an infinite loop, unless the user would enter 'quit' into the console.
Reply
#4
Hi,
Your problem is that on line 13, you are missing an extra bracket at the end. Also your control variable should be on global.
Hope it helps and that I am not too late. Smile
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020