Feb-13-2022, 03:47 PM
Hello,
Trying to sum string numbers to int, but there is a ; between them.
Thank you
Trying to sum string numbers to int, but there is a ; between them.
tab = input("Éntrez les nombres entiers séparés par des (;) : ") list_nb= [tab] list_nb = [item.replace(";"," ") for item in list_nb] nbs = list(map(int, list_nb)) somme = 0 for nb in nbs: print((somme + nb)/len(nbs))
Error:Éntrez les nombres entiers séparés par des (;) : 4;5;7;
Traceback (most recent call last):
File "<string>", line 10, in <module>
ValueError: invalid literal for int() with base 10: '4 5 7 '
>
Why i get this error. Numbers need to be input with ";"Thank you