estoy comenzando a programar en Python, y mi duda es la siguiente:
mi programa si corre, sin embargo al querer salir del bucle, me arroja el siguiente error:
def pcn_loop3():
while True:
x = int(input("Ingrese un numero ('*' para terminar): "))
if x == '*':
break
elif x > 0:
print("Numero positivo")
elif x == 0:
print("Igual a 0")
else:
print("Numero negativo")
Ingrese un numero ('' para terminar): 3
Numero positivo
Ingrese un numero ('' para terminar):
Traceback (most recent call last):
File "", line 1, in
pcn_loop3()
File "C:\01_Mis.Documentos\01 Mis Programas en Python\Mis proyectos\kk.py", line 3, in pcn_loop3
x = int(input("Ingrese un numero ('' para terminar): "))
ValueError: invalid literal for int() with base 10: '*'
Y no puedo hacer que salga del bucle y si le quito int a la variable x me arroja el siguiente error:
Ingrese un numero ('*' para terminar): 3
Traceback (most recent call last):
File "", line 1, in
pcn_loop3()
File "C:\01_Mis.Documentos\01 Mis Programas en Python\Mis proyectos\kk.py", line 6, in pcn_loop3
elif x > 0:
TypeError: unorderable types: str() > int()
Como hago que salga del ciclo infinito, sin que me arroje un error...?