0

How can i repeat an operation

In calculators if you type 4 (times) 3 and press = it gives 12 (of course) and when you press it again it gives 36 and so on (because 4 times 3 is 12 and 12 times 3 is 36). How can i do this in python? (repeat an operation when the user wants to)

17th Oct 2018, 4:15 PM
Juho Pesonen
Juho Pesonen - avatar
1 Answer
+ 2
Save the last used operator and operand in variables and whenever the user presses = again, apply operator and operand to the current result
17th Oct 2018, 5:22 PM
Anna
Anna - avatar