Jul-18-2017, 06:26 AM
my question here
create a 20 digit string, and cast to a list
then add all the digits as integers
print the equation and answer
Hint: use cast to sum the digits, and .join() to create the equation (1+2+3+...)
create a 20 digit string, and cast to a list
then add all the digits as integers
print the equation and answer
Hint: use cast to sum the digits, and .join() to create the equation (1+2+3+...)
new_digit="20,10,70,30,20" print(list(new_digit)) sum_of_digits=0 new_digit=int(new_digit) for digits in new_digit: #digits=int(digits) sum_of_digits+=digits print("+".join(new_digit))But I am getting ValueError: invalid literal for int() with base 10: '20,10,70,30,20'