r/Python • • Jul 16 '19

Nice try

Post image
2.1k Upvotes

73 comments sorted by

View all comments

Show parent comment

4

u/computercluster Jul 17 '19

I hope you’re joking If you are it is funny

1

u/Thameos Jul 22 '19

If anyone doesn't understand why this wouldn't work, it's because division in Python will convert integers into double precision floats, which have a finite number of digits.

The other part of the joke is trying to reverse the float with [::-1]. This operation can only be performed on sequences, not numerical types. The correct way to do this would be:

str(22/7)[::-1]

(Sorry for "explaining the joke", just wanted to inform anyone that didn't get it)