- Joined
- Jul 6, 2006
- Messages
- 666 (0.10/day)
- Location
- England, UK
Processor | AMD Athlon 3800+ X2 |
---|---|
Motherboard | ASUS A8N-SLI SE |
Cooling | 2 Exhaust fans |
Memory | 2x512MB DDR400 RAM |
Video Card(s) | Connect3D ATI Radeon X1900XT 512MB |
Storage | 80GB Maxtor DiamondMax |
Display(s) | Packard bell 17" CRT |
Case | Stock |
Power Supply | 580W Hiper Type-R |
Hey programming wizards,
I'm trying to write a basic menu system after getting some inspiration off a few youtube videos. I'm very new to python and somewhat new to programming (know a little C#).
def select():
choice = int(input('Enter choice number: '))
if (choice == 1):
C2F()
if (choice == 2):
F2C()
if (choice == 3):
I2C()
if (choice == 4):
C2I()
if (choice == 5):
G2L()
if (choice == 6):
L2G()
if (choice == 7):
Y2M()
if (choice == 8):
M2Y()
if (choice == 9):
P2K()
if (choice == 10):
K2P()
else:
print ("Number", choice, "is an invalid selection");
print ("Bye-bye.");
What i'm trying to do is get the menu to loop with the message 'number x is an invalid selection' should they enter a number outside of the 1-10 range. If i remember from C# i used to be able to do a 'do while' loop but while i've looked at 'For' and 'While' loops here i'm on figuring out how to implement them, maybe my if statements need to be reworked in order to get another type of nested loop going?
Seany
I'm trying to write a basic menu system after getting some inspiration off a few youtube videos. I'm very new to python and somewhat new to programming (know a little C#).
def select():
choice = int(input('Enter choice number: '))
if (choice == 1):
C2F()
if (choice == 2):
F2C()
if (choice == 3):
I2C()
if (choice == 4):
C2I()
if (choice == 5):
G2L()
if (choice == 6):
L2G()
if (choice == 7):
Y2M()
if (choice == 8):
M2Y()
if (choice == 9):
P2K()
if (choice == 10):
K2P()
else:
print ("Number", choice, "is an invalid selection");
print ("Bye-bye.");
What i'm trying to do is get the menu to loop with the message 'number x is an invalid selection' should they enter a number outside of the 1-10 range. If i remember from C# i used to be able to do a 'do while' loop but while i've looked at 'For' and 'While' loops here i'm on figuring out how to implement them, maybe my if statements need to be reworked in order to get another type of nested loop going?
Seany