Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Funções
- def adicionarNumLista(numero):
- listNum.append(userNum)
- #Variaveis
- listNum = []
- count = 0
- userNumCount = int(input("Digite quantos números irá inserir na lista: "))
- while count < userNumCount:
- if userNumCount < 2:
- print("Deve digitar mais que 2 números.")
- break
- else:
- try:
- userNum = int(input("Digite um numero inteiro para ser adicionado na lista: "))
- except Exception:
- print("Digite apenas números inteiros.")
- break
- adicionarNumLista(userNum)
- count += 1
- print(f"\nA soma de todos valores da lista é: {sum(listNum)}")
Advertisement
Add Comment
Please, Sign In to add comment