I'm practicing loops in Python and started trying to have a better approach with user inputs, is there better ways of dealing with inputs when coding? And I tried using deques too, it worked very well, but don't know if I should or need to; are deques better in this case or should I keep using lists?
sum_numbers: list = list()
for question in range(1, 11):
while True:
try:
print(f'{question}º number: ')
asnwer = float(input('-> ').strip().replace(',', '.'))
except ValueError:
print('Invalid input! Try again...\n')
continue
else:
sum_numbers.append(asnwer)
break
print(
'\nNumbers:\n'
f'{sum_numbers}\n'.replace('[', '').replace(']', '') +
f'\nSum: {sum(sum_numbers)}.'
)
9,263
? \$\endgroup\$pt-PT
, whose decimal separator is a comma. I have suggestions on how to better handle this. \$\endgroup\$