LipeMachado

Tarefa 3

Aug 17th, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. #Funções
  2. def adicionarNumLista(numero):
  3.     listNum.append(userNum)
  4.  
  5. #Variaveis
  6. listNum = []
  7. count = 0
  8. userNumCount = int(input("Digite quantos números irá inserir na lista: "))
  9.  
  10. while count < userNumCount:
  11.     if userNumCount < 2:
  12.         print("Deve digitar mais que 2 números.")
  13.         break
  14.     else:
  15.         try:
  16.             userNum = int(input("Digite um numero inteiro para ser adicionado na lista: "))
  17.         except Exception:
  18.                 print("Digite apenas números inteiros.")
  19.                 break
  20.         adicionarNumLista(userNum)
  21.         count += 1
  22.  
  23. print(f"\nA soma de todos valores da lista é: {sum(listNum)}")
Advertisement
Add Comment
Please, Sign In to add comment