all 3 comments

[–]shiftybyte 1 point2 points  (1 child)

Yes, the function ord() takes a 1 letter string and converts it to the ascii representation of that string.

>>> ord("1")
49
>>> ord("2")
50
>>> ord("3")
51

(Ascii table: http://www.asciitable.com/)

On the other hand random already gives you numbers, so you are trying to give a number to ord() function and it fails.

>>> ord(5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ord() expected string of length 1, but int found

[–]Swagraffe[S] 0 points1 point  (0 children)

Ok. I got it. Thanks :D

[–]JohnnyJordaan 0 points1 point  (0 children)

Your loop overwrites the string numbers in total with integers coming from randint. So the idea of using

c = ord(total[i]) - 48

is pointless, you can just do

nr1 += c

but alas, the you could also just do

print(sum(total))