Created
December 13, 2016 12:56
-
-
Save renzon/9389b92a488c25a88b78484efb9aae8a to your computer and use it in GitHub Desktop.
Obtém qdt de número como input definida pela constante N
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = 2 | |
lst = [0] * N | |
try: # Mantenha no try só o que pode dar pau | |
for i in range(N): | |
lst[i] = float(input('%sº número: ' % (i + 1))) | |
except(ValueError, TypeError): | |
print('Valor inválido') | |
else: # Aqui vai o código se não houve erro | |
print('primeiro elemento:', lst[0]) | |
print('A soma dos numeros %s é %f' % ('; '.join(map(str, lst)), sum(lst))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment