0

I am a new python user, I have a project which is drawing 2 pictures. I have done it already, however I don't know how to make a menu to ask the user repeatedly like this:

1:Draw picture 1
2. Draw picture 2
3. Exit
Enter an option (1/2/3):

and the other options will cause error Can anyone help me?

Edit 1 : (Posted from comments)

import picture1 
import picture2
while True: 
  menu=raw_input("Menu\n 
  1.Draw multi polygons\n 
  2.Draw flower\n 
  3.exit\n Enter an option(1/2/3): ") 
  if menu == "1":
    return True
  elif menu == "2":
    return False
  else:
    menu == "3": break
rbaleksandar
  • 8,713
  • 7
  • 76
  • 161
  • post your efforts as well .. – Tharif Jul 31 '15 at 04:23
  • import picture1 import picture2 while True: menu=raw_input("Menu\n 1. Draw picture1\n 2.Draw picture2\n 3.exit\n Enter an option(1/2/3): ") if menu == "1": print picture1 elif menu == "2": print picture2 elif menu == "3": break /this is what I have done so far, but it keep show the picture first without the menu – BussIn Boots Jul 31 '15 at 04:31
  • Code is not readable in comments and is better put in the question. What are you trying to do when you type `import picture 1`? – Paul Rooney Jul 31 '15 at 04:32
  • because picture in the different slide, so I think I must import it in the menu slide. – BussIn Boots Jul 31 '15 at 04:33
  • Also, can you please [edit] your question to fix the whitespacing? – NightShadeQueen Jul 31 '15 at 04:35
  • I already did that. :) – rbaleksandar Jul 31 '15 at 04:36
  • Btw it is generally a good practice to keep one return type for a function (yes, Python allows multiple but it might get confusing). In your if-elif-else statement you have 2 returns of boolean type and one that doesn't return anything at all. I presume this is supposed to be a function of some sort so in the case the last else statement is executed and you assign the output of your function to some variable what do you expect to happen? :) – rbaleksandar Jul 31 '15 at 04:39

0 Answers0