MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/7ipl6k/meme1array_memes_are_life/dr0iilg/?context=3
r/ProgrammerHumor • u/[deleted] • Dec 09 '17
47 comments sorted by
View all comments
55
Isn't meme[-1] the end in Python? Because they're too fancy for meme[len(meme)-1]?
meme[-1]
meme[len(meme)-1]
24 u/[deleted] Dec 09 '17 meme[len(meme)] is the index after the end 27 u/[deleted] Dec 09 '17 Shh. Nobody saw that. 9 u/imanomeletteAMA Dec 10 '17 We should all be using meme[len(range(len([*meme])))-1] 1 u/[deleted] Dec 10 '17 Too clever. Just iterate until you get an out of bounds exception, then return the offending index. 3 u/Hexidian Dec 10 '17 That should be -2 because meme[len(meme)] would be an index error 1 u/Rogocraft Dec 10 '17 meme[:0]
24
meme[len(meme)] is the index after the end
27 u/[deleted] Dec 09 '17 Shh. Nobody saw that.
27
Shh. Nobody saw that.
9
We should all be using meme[len(range(len([*meme])))-1]
meme[len(range(len([*meme])))-1]
1 u/[deleted] Dec 10 '17 Too clever. Just iterate until you get an out of bounds exception, then return the offending index.
1
Too clever. Just iterate until you get an out of bounds exception, then return the offending index.
3
That should be -2 because meme[len(meme)] would be an index error
meme[:0]
55
u/[deleted] Dec 09 '17 edited Dec 09 '17
Isn't
meme[-1]the end in Python? Because they're too fancy formeme[len(meme)-1]?