Sep-24-2018, 10:51 AM
Hi guys, i'm just learning how to program in Python and i'm have some problems...
I'm testing the functions and this is my code:
##I want a simple code that tells you to type name and age then the program will tell it again.
##But i'm having problems with the while loop. I want it to ask again if an int is not typed for the age, but
##this code apparently is not enough. I've tried a lot of things, with if and exceptions, but i just can't.
##Can you help me please?
def display(nome, idade):
print("Seu nome é", nome, "e sua idade é", idade) #Your name is: // Your age is:
age = None
name = input("Qual o seu nome?") #What's your name?
while type(age) != int:
age = input("Qual a sua idade?") #How old are you?
print("O valor digitado não é um número inteiro") #The typed value is not an integer
display(name, age)
I'm testing the functions and this is my code:
##I want a simple code that tells you to type name and age then the program will tell it again.
##But i'm having problems with the while loop. I want it to ask again if an int is not typed for the age, but
##this code apparently is not enough. I've tried a lot of things, with if and exceptions, but i just can't.
##Can you help me please?
def display(nome, idade):
print("Seu nome é", nome, "e sua idade é", idade) #Your name is: // Your age is:
age = None
name = input("Qual o seu nome?") #What's your name?
while type(age) != int:
age = input("Qual a sua idade?") #How old are you?
print("O valor digitado não é um número inteiro") #The typed value is not an integer
display(name, age)