Int/str conversions broken in latest Python bugfix releases

Just for awareness, this has also broken a number of problem set for students. For example, “What is the leading / trailing / 500th digit of 4^(5^6)? How many times does each digit appear?”. Students used to be able to solve by doing something like:

n = 4 ** (5 ** 6)
s = str(n)
print(s[0], s[-1], s[-500]))

from collections import Counter
print(Counter(s))

Of course, the second line now raises a ValueError since our cloud learning environments have all updated to the latest patch release.

8 Likes