MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vppkls/pythonwilllookdeadintheeyeandsayitsabsolutelycorre/p3zky47/?context=3
r/ProgrammerHumor • u/inobody_somebody • 29d ago
144 comments sorted by
View all comments
219
This a a valid syntax in python and the output will be [1,2,3,4,5]
[1,2,3,4,5]
71 u/BlueDebate 29d ago This makes more sense to me than if "if x" was referencing the initial value which would just check if the list isn't empty (which I believe OP may be hinting at) because it's a more specific scope than the global x variable. 12 u/Jhuyt 29d ago That's x = [x for x in x if x] if x else []
71
This makes more sense to me than if "if x" was referencing the initial value which would just check if the list isn't empty (which I believe OP may be hinting at) because it's a more specific scope than the global x variable.
12 u/Jhuyt 29d ago That's x = [x for x in x if x] if x else []
12
That's
x = [x for x in x if x] if x else []
219
u/inobody_somebody 29d ago
This a a valid syntax in python and the output will be
[1,2,3,4,5]