How do I add five numbers from user input in Python?

前端 未结 5 1682
时光说笑
时光说笑 2021-01-16 08:49

As a practice exercise, I am trying to get five numbers from a user and return the sum of all five number using a while loop. I managed to gather the five numbers, but the

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-16 09:02

    Adding str or int by user_input & then printing the result - Adding 2 or more no's from users input

    example from the abv link

    '''Two numeric inputs, explicit sum'''
    
    x = int(input("Enter an integer: "))
    y = int(input("Enter another integer: "))
    sum = x+y
    sentence = 'The sum of {} and {} is {}.'.format(x, y, sum)
    print(sentence)
    

提交回复
热议问题