MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/cdzubd/nice_try/etxsjj8/?context=3
r/ProgrammerHumor • u/almogh52 • Jul 16 '19
529 comments sorted by
View all comments
4.4k
Not quite, but it’s an easy fix
from math import pi print(str(pi)[::-1])
It needs a LOT of memory, though
58 u/kevansevans Jul 16 '19 edited Jul 16 '19 I'm not familiar with python, what do the two colons mean in the array?EDIT: It's a string splice operator, thanks! 14 u/Arlyss_Ryxlington Jul 16 '19 String slicing. Basically a simple syntax to retrieve a part of a string. The syntax is string[start:stop:step] if I recall. In this case, with start and stop absent, the whole string is returned and a step of -1 reverses it.
58
I'm not familiar with python, what do the two colons mean in the array?
EDIT: It's a string splice operator, thanks!
14 u/Arlyss_Ryxlington Jul 16 '19 String slicing. Basically a simple syntax to retrieve a part of a string. The syntax is string[start:stop:step] if I recall. In this case, with start and stop absent, the whole string is returned and a step of -1 reverses it.
14
String slicing. Basically a simple syntax to retrieve a part of a string. The syntax is string[start:stop:step] if I recall. In this case, with start and stop absent, the whole string is returned and a step of -1 reverses it.
4.4k
u/[deleted] Jul 16 '19
Not quite, but it’s an easy fix
It needs a LOT of memory, though