For a menu, just make a new function. Have it print out the choices on screen, including a number, and then the option is chosen by inputing a number. You could use the raw_input() function, but this is rather crude, as it throws errors, if it recieves a value that it does not have a statement for.
I suppose you could use an 'else' statement, which then starts the menu again. Try it and come back to me if you need more help.
SgtMe
Nearly a Posting Virtuoso
1,205 posts since Oct 2009
Reputation Points: 68
Solved Threads: 85
Oh my God!
You are using a wild mix of tabs and spaces for your code indentations! That is an absolute nono.
Avoid tabs, since sooner or later you will mix them with spaces. Most Pythonians use 4 spaces for indenting a code block. Stick with that!
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
I always use the tab key. It just looks neater to me...
SgtMe
Nearly a Posting Virtuoso
1,205 posts since Oct 2009
Reputation Points: 68
Solved Threads: 85
I always use the tab key. It just looks neater to me...
Many editors use different tab settings, so your code can look rather messy to someone else. Just take a look at slmsatish's tabbed code on the post before. Also, if you want to convert your code to Python3 syntax with the 2to3 .py utility program, forget it! That one hates tabs, rightfully!
Most editors written for programming in Python will do the proper indentations for you, but may not translate tabs correctly. I generally refuse to even check out code that uses tabs. Looks like junk on my editor.
Python is an indentation based syntax, why screw it up with inconsistent tabs.
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
sorry vegaseat, but I use Notepad, NOT NOTEPAD++
Ich bin der MS-Noob
SgtMe
Nearly a Posting Virtuoso
1,205 posts since Oct 2009
Reputation Points: 68
Solved Threads: 85
I don't like IDLE. I was using netbeans but it got annoying, cos even if I wanted to test something small before I put it in a program, I had to make a new project. The only advantages of netbeans is that it shows typing errors as you go, and freezes any errors that come up so you don't have to print screen and paste in paint!
SgtMe
Nearly a Posting Virtuoso
1,205 posts since Oct 2009
Reputation Points: 68
Solved Threads: 85
Just a note:
NotePad is for writing little notes. Yes, you can use a screwdriver as a hammer, but you really should use the right tools for the job. If your job is writing Python programs use IDLE, SPE, DrPython, PyScripter, Editra, or one of the many other Python specific offerings.
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
I disagree. Though there are advantages to using full IDEs such as netbeans, Notepad's simplicity still does it for me. It's free from clutter, and you don't have to fiddle around with settings and installation and whatever. It's there, it works, it's done. Just like using a belt sander to sand down a 1cm by 1cm piece of wood...
SgtMe
Nearly a Posting Virtuoso
1,205 posts since Oct 2009
Reputation Points: 68
Solved Threads: 85
Though there are advantages to using full IDEs such as netbeans
Vega is not talking about big editors like netbean that support many languages.
Pyscripter,SPE are small python editors that work out the box,just paste in code an run it.
And will give a god error message and where in code if somthing goes wrong.
snippsat
Practically a Posting Shark
808 posts since Aug 2008
Reputation Points: 353
Solved Threads: 294