-1
name = " "
Age = " "
Gender = " "
people = []
ages = []
while  name != "":
### This is the Raw data input portion and the ablity to stop the program and exit
    name = input("Enter a name or type done:")
    if name == 'done' : break
    Age = input("How old are they?")
    Gender = input("What is their gender M/F?")
### This is where I use .append to create the entry of the list     
    people.append(name)
    people.append(Age)
    ages.append(Age)
    people.append(Gender)
print("list of People:", people)

print(ages)

when I get results the list comes out like this

list of People: ['jim', '12', 'F', 'Ann', '12', 'F']
['12', '12']

how can I remove the '' between each entry its making me have trouble useing the Mean function to pull a average from the ages list

help !!!

kevin
  • 27
  • 3

1 Answers1

1

The problem is, that input always returns a string. Just use int to turn it into an integer:

Age = int(input("How old are they?"))

But be aware that this will throw a ValueError, if you don't enter a number. You can handle the error using a try/except, if you want to. You could cancel the input for the current person and print an error message and then start with a new person:

try:
    Age = int(input("How old are they?"))
except ValueError:
    print("Invalid input.")
    continue
Leon
  • 2,926
  • 1
  • 25
  • 34