One way I can suggest is
x=0; ham=''; b=['s','p','a','m'] #or, b=('s','p','a','m')
> for t in b:
> ham=ham+b[x]
> print(ham);x+=1
>
>
> 't' is actually equal to b[x] and its faster then indexed based look-up.
so you can rewrite
ham = ham + b[x]
as
ham += t
and remove the x inc
Hi,
I am trying to learn how Python stores variables in memory. For ex:
my_var = 'test'
def func():
pass
when I type dir() I get
['__builtins__', '__doc__', '__name__', '__package__', 'func', 'help',
'my_var']
are these variables stored in a dict and on calling dir() all the keys are
retu
My guess is you are using Python version >2.6 where "set" is a built-in.
You can fix this by doing the following.
1) Remove "from sets import Set"
2) And replace "alphabet = list(Set(stList))" with "alphabet =
list(set(stList))"
This should work straight away.
P.S Its "Python" not phyton
Cheers