#Ur syntax might be wrong

1 messages · Page 1 of 1 (latest)

empty heart
#

Create an init func for solution

#

Initialize array therr

#

Initialize array in Solutions

#

init(self)

#

Function

#

Oh it didnt get my underscores

vale chasm
#

ohhh ok ok let me try that

empty heart
#

Google python init if udk it

#

Im too lazy cause im in bed rn

#

To format my msg properly

vale chasm
#

thanks so much! thats all i needed

#

wowwww

#

ok ok wait so i cant just make global variables like that?

empty heart
#

In ur kthSest

#

kthSmallest

#

Ur calling self.array

#

Im ur old code

#

Python interpreter doesnt know if class has a self.array

#

Does that make sense?

#

Theres a bunch of reasons

vale chasm
empty heart
#

Just keep practicing and reading python syntax

vale chasm
#

would it have worked?

empty heart
#

Unsure

#

Probably not though

#

Youd need some

#

Nonlocal

#

Or global keyword

#

In kthSmallest

vale chasm
empty heart
#

In classes

#

U use init

#

If there was no class Solution

#

Ur old solution would have worked if u made self.array just array

vale chasm
#

thanks a lot!