Python Forum

Full Version: outcome 0 but impossiblenumbers change
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i= 1
top_hat= []
while i<=5:
    try:
        top_hat.append(int(input('Please enter your top hat score: ')))
        i+=1
    
    except:
        print('Please enter valid number: ')

print(top_hat)

top_hat_total=[]
for x in top_hat_total: 
        top_hat_total.append(x*(2/100))

print('your total percentage from top hat is: '  + str(sum(top_hat_total))) 
No matter what i enter for numbers at the end it prints out as 'your total percentage from top hat is:0'
Why?
you are looping top_hat_total which is an empty list
for x in top_hat_total:
did you mean to loop top_hat
for x in top_hat: