Dec-23-2016, 05:27 AM
Quote:now how i can loop through the input value?It's soon Christmas ,so this should help

1 2 3 4 5 6 7 8 9 10 11 12 |
def hm_cars(user_input): income = [] if user_input < = 0 : return for number in range ( 1 , user_input + 1 ): income.append( int ( input ( 'Income car:{}' . format (number)))) return income user_input = int ( input ( 'How many cars do you have? ' )) cars = hm_cars(user_input) print (cars) print ( 'Sum of all cars income {}' . format ( sum (cars))) |