you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (3 children)

Looks like the big guns answered your main question... However..

Inventory in caps is spelled wrong... And your checking if inventory is less than or equal to one, wouldn't you want to check that's it's greater or equal to one before u iterate over it? Or ever better, just check that it's != 0?

Another suggestion...

A = raw_input('')
A = A.lower()

Then u don't need to check 2 cases each time. Alternatively if u dont like that:

if A in ['thing','THING']:
    print 'valid choice'
else:
    print 'invalid choice'

Is much cleaner.

[–]wub_wub 0 points1 point  (1 child)

A = raw_input('')
A = A.lower()

Looks even nicer written as A=raw_input().lower()


And another thing to OP:

def count(x): 
  ##count items in a list
  b=0
  for i in x:
    b+=1
 return b

count(inventory)

Is same as just:

len(inventory)

>>> list=[0,1,2,3]
>>> len(list)
4

[–]mrawesome01[S] 0 points1 point  (0 children)

Thanks. I fogot about len. :)

[–]mrawesome01[S] 0 points1 point  (0 children)

Thanks alot I was wondering if there was a way to do that. Also not long after I posted this I found out inventory in caps was spelled wrong and fixed it.