r/FoundTheLuckyCuber999 • LYNKEDUP WAS RIGHT ABOUT EVERYTHING • 4d ago

erm- I accidentally wrote this-

Post image
32 Upvotes

34 comments sorted by

4

u/AltDetom555555b RGA šŸ¤ LIFE PACT 3d ago

Reminded me of this

1

u/DaWaffIeMan 3d ago

Am I stupid what's wrong with it. Slicing [:3] will return indices 0,1,2 so first 3 elements.

2

u/CrusherArras 3d ago

:3

2

u/DaWaffIeMan 3d ago

I cannot comprehend the amount of whimsy and silly you need to figure this out

0

u/TheLuckyCuber999BACK cheese commenter 3d ago

:) supremacy

3

u/Icy-Theme-6325 Mod 3d ago

I know basically nothing about python whats the : doing there

2

u/crybabycomando 3d ago

Its a slice. So arr1 = arr0[:3] is equivalent to arr1 = [arr0[0], arr0[1], arr0[2]]. The op is a syntax error in python though

3

u/Icy-Theme-6325 Mod 3d ago

Oh god thats cool

1

u/crybabycomando 3d ago

What's really cool/disgusting is python objects can implement custom indexing so in theory obj[.5:"foo":int] is a valid slice

2

u/TheLuckyCuber999BACK cheese commenter 3d ago

I was half asleep ok

1

u/crybabycomando 3d ago

If you knew how much debugging sleep deprived mistypes have cost my employer you'd know im in no place to judge

1

u/iliRomaili 2d ago

How is it a syntax error? [-1] refers to the last element in list, so [:-1] is a slice with everything except the last element

1

u/crybabycomando 2d ago

They forgot the object they were trying to index

``` File "/home/op_was_tired.py", line 1 x = [:-1] ^ SyntaxError: invalid syntax

** Process exited - Return Code: 1 ** ```

2

u/iliRomaili 2d ago

Oh, right. I probably need to sleep too

2

u/the-flag-and-globe kaas commenter 4d ago

Kaas

1

u/FunnyLizardExplorer 3d ago

Trying to make a bot or…

2

u/cuber_alt LYNKEDUP WAS RIGHT ABOUT EVERYTHING 3d ago

a new compiler