Showing posts with label sum of digits. Show all posts
Showing posts with label sum of digits. Show all posts

Wednesday, July 8, 2015

Print the sum of digits of numbers starting from 1 to 100 (inclusive of both)



print sum(range(1,101))


Create a new list that converts the following list of number strings to a list of numbers.
num_strings = ['1','21','53','84','50','66','7','38','9']

[int(i) for i in num_strings]
[1, 21, 53, 84, 50, 66, 7, 38, 9]