Still trying to understand python. It is so different than php.
I set the choice to integer, the problem is on my menu I need to use letters as well.
How can I use integer and string together?
Why can I not set to string than integer?
def main(): # Display the main menu
while True:
print
print " Draw a Shape"
print " ============"
print
print " 1 - Draw a triangle"
print " 2 - Draw a square"
print " 3 - Draw a rectangle"
print " 4 - Draw a pentagon"
print " 5 - Draw a hexagon"
print " 6 - Draw an octagon"
print " 7 - Draw a circle"
print
print " D - Display what was drawn"
print " X - Exit"
print
choice = raw_input(' Enter your choice: ')
if (choice == 'x') or (choice == 'X'):
break
elif (choice == 'd') or (choice == 'D'):
log.show_log()
try:
choice = int(choice)
if (1 <= choice <= 7):
my_shape_num = h_m.how_many()
if ( my_shape_num is None):
continue
# draw in the middle of screen if there is 1 shape to draw
if (my_shape_num == 1):
d_s.start_point(0, 0)
else:
d_s.start_point()
#
if choice == 1:
d_s.draw_triangle(my_shape_num)
elif choice == 2:
d_s.draw_square(my_shape_num)
elif choice == 3:
d_s.draw_rectangle(my_shape_num)
elif choice == 4:
d_s.draw_pentagon(my_shape_num)
elif choice == 5:
d_s.draw_hexagon(my_shape_num)
elif choice == 6:
d_s.draw_octagon(my_shape_num)
elif choice == 7:
d_s.draw_circle(my_shape_num)
d_s.t.end_fill() # shape fill color --draw_shape.py-- def start_point
else:
print
print ' Number must be from 1 to 7!'
print
except ValueError:
print
print ' Try again'
print