![]() |
|
#1
|
|||
|
|||
Simple guessing game: missing spacesI am a newbie when it comes to writing code. I did some research and tought that I will learn Python first, as it will be usefull ofr my future goals.
I have tried to do some exercises and have created a very simple guessing game. The game works, however I am having a problem with the code. I am wondering if someone will be able to look at the code and tell me what I am doing wrong. Thank you very much Python Code:
The problem i am getting is that when I run the game the last sentence doesn't seperate and is together Code:
What am I doing wrong Last edited by LuciWiz : 10-Nov-2008 at 06:32.
Reason: Please insert your Python code between [py] & [/py] tags
|
|||
|
#2
|
||||
|
||||
Re: HelpWithout being a Python programmer, I assume filling-in the desired spaces when printing out the strings ought to do it:
Python Code:
__________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#3
|
||||
|
||||
Re: Simple guessing game: missing spacesLuciWiz is right, you just have to add the spaces manually.
Additionally, I thought I'd help optimize your code. Don't think that you did it wrong. As long as it works, it's a success. I just wanted to give you some pointers that will make your life easier in the future because you will end up writing less code and it will be easier to maintain. Python Code:
Alternatively, you can also try string formatting the numbers. For example, the last line could be Python Code:
__________________
Start Programming with Python-A beginner's guide to programming and the Python language. ------------- Common Sense v2.0-Striving to make the world a little bit smarter. |
|
#4
|
|||
|
|||
Re: Simple guessing game: missing spacesThank you guys for all your help. Thanks for the pointers I realy appreciate it. I need all the tips and tricks I can get my hands on. Thanks again
|
|
#5
|
|||
|
|||
Re: Simple guessing game: missing spacesSorry for the doublepost guys I have another question to ask.
I would like to improve this code make a more efficent version. I don't want people to write the code, but to give me some ideas and tips. I would like to test myself, so if you have any tips please put them here but not in code please Thank you |
|
#6
|
||||
|
||||
Re: Simple guessing game: missing spacesWell, my first suggestion is to put a function or two in it.
__________________
Start Programming with Python-A beginner's guide to programming and the Python language. ------------- Common Sense v2.0-Striving to make the world a little bit smarter. |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The