dict.keys()[0] on python 3
i have this sentence:
def Ciudad(prob):
numero = random.random()
ciudad = prob.keys()[0]
for i in prob.keys():
if(numero > prob[i]):
if(prob[i] > prob[ciudad]):
ciudad = i
else:
if(prob[i] > prob[ciudad]):
ciudad = i
return ciudad
but when i call it this error pops: TypeError: 'dict_keys' object does not
support indexing
is it a version problem? i'm using python 3.3.2
No comments:
Post a Comment