jon.kiparsky, on 12 December 2012 - 12:55 PM, said:
No sweat. Best of luck!
As you get the hang of this, you might find that it works better to do this in a list comprehension or a filter - those seem more "pythonic" approaches to this sort of problem - but for now, just getting away from the iteration by index will help a lot.
As you get the hang of this, you might find that it works better to do this in a list comprehension or a filter - those seem more "pythonic" approaches to this sort of problem - but for now, just getting away from the iteration by index will help a lot.
I tookunder consideration all you said about indexes
import random
lists=[[150, 9, 'drop'], [35,13,"cage"],[200,153,"lust"],[160,50,"google"],[60,15,"gun"],[45,68,"razor"],[60,27,"armor"] ]
x=random.sample(lists, 5)
theitems=[]
for i in range(len(x)):
theitems.append(x[i][2])
print theitems
tw=0
tv=0
while True:
epilogi=raw_input("choose")
z=0
for i in theitems:
if i==epilogi:
tw=tw+x[z][1]
tv=tv+x[z][0]
theitems.remove(i)
x.remove(x[z])
z=z+1
print theitems,x

New Topic/Question
Reply




MultiQuote






|