My first code - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: My first code (/thread-2261.html) |
My first code - Flappo - Mar-02-2017 My first code I've ever made in python doesn't work and I don't know why. Please can you help me solve the issue. Code: age = 10; if age < 9: print("Hey! ") print("Welcome to play with us") else print("You're too old for this gang!")Error code:
RE: My first code - micseydel - Mar-02-2017 I'm not sure where you saw "%Run" and thought it would work. It looks like you were in a command prompt and typed "python" to get the >>>. Instead, go back to that and type "python your_script_name.py". I recommend not using test.py as a name, for reasons that I don't want to overwhelm you with as a brand-new programmer. RE: My first code - Flappo - Mar-02-2017 (Mar-02-2017, 05:10 PM)micseydel Wrote: I'm not sure where you saw "%Run" and thought it would work. I used Thonny to write and run the code. But do you have to solution to my problem? RE: My first code - micseydel - Mar-02-2017 Apologies, I misread the original problem. You need a colon after "else" RE: My first code - Flappo - Mar-02-2017 Thanks! RE: My first code - wavic - Mar-02-2017 In Python there is no ';' after a statement. Only if you do it on on line: a = 2; b = 3; c = 'four'Or may be I am wrong. Just tried it. Hm! :D RE: My first code - stamnik - Mar-02-2017 try this code :)
age = 10 ## no need ;
if age < 9: print("Hey! ") print("Welcome to play with us") else: ## need : print("You're too old for this gang!") |