Hi, I'm a beginner to Python and have been struggling with this assignment since yesterday: the user gives 2 numbers and then selects an action (1-6). If the selection is 5 then the user can change the given numbers and that's where I don't know how to proceed because the whole structure needs to be displayed again.
Here's my code:
When running this and selecting 5, the paragraphs "(1) + \n(2) -\n(3) *\n(4) /" and the rest are no longer shown
Here's my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
print ( "Calculator" ) def Loop(): number1 = int ( input ( "Give the first number: " )) number2 = int ( input ( "Give the second number: " )) print ( "(1) +" ) print ( "(2) -" ) print ( "(3) *" ) print ( "(4) /" ) print ( "(5)Change numbers" ) print ( "(6)Quit" ) print ( "Current numbers: " ,number1,number2) select = int ( input ( "Please select something (1-6): " )) if select = = 5 : Loop() if select = = 1 : print ( "The result is:" , number1 + number2) elif select = = 2 : print ( "The result is:" , (number1 - number2)) elif select = = 3 : print ( "The result is:" , number1 * number2) elif select = = 4 : print ( "The result is:" , number1 / number2) else : print ( "Selection was not correct." ) Loop() |