0

How can I use goto in Python?

Hello, I'm trying to code my first "calculator" and I remember in C++ there's goto and it is very easy to use, but in Python I don't understand very well how does it work. I will thank you so much if you tell me how to use it or use something similar. elif operation == 1: #Suma #Here would be the equivalent to 'suma:' os.system("cls") print("Haz seleccionado suma. Este programa realiza la función \'a + b = c\'.\nEscribe los valores deseados.") a = int(input("Valor de a: ")) b = int(input("Valor de b: ")) c = a + b print("El valor de c es " + str(c)) respuesta = input("¿Deseas realizar otra suma? Escribe 1 para \'sí\' y 0 para \'no\' (serás devuelto al menú): ") if respuesta == 1: #Here I want to put the equivalent to 'goto suma;' else: #Here I want to put another goto but a 'goto menu;' NOTE: I'm using Python 3.8 xd idk if that's important

24th Feb 2020, 1:44 PM
Leonardo Diego
Leonardo Diego - avatar
1 Antwort
+ 1
Goto statements are removed or never used in some modern programming languages, atleast Java and Python shouldn't have it.
24th Feb 2020, 2:02 PM
Seb TheS
Seb TheS - avatar