need some python help, is there is a way to generate different variable names in a loop
What do you mean? Can't you use a list/array?
Sorry, I just don't understand why you would need to generate new variable names, if you just need many variables you could just do for example x = [] for i in range(4): x.append(i) x[2] = 1000 Here I create an array and successively add the elements 0,1,2 and 3 to the array, then I change the third element (arrays start from 0) to 1000. I don't know if this is what you want or if I am just misunderstanding the question.
@dape
hey hey 1 second!! ill tell you exactly where i am stuck
iam really new to this programming stuff, i just started python a couple days ago
okay so i have this dictionary
with a key= the names of the places
keys*=names of the corresponding places
Okay, what's the value?
and its values for each key are a list of information corresponding to each place
Alright
now what I want to do with this dictionary is
I have this class called class card(object): it take take in the parameters position, price,rent,color....
what I want to do is to take each key, and instead of a value of list.. i want the value to be a card object
can yo do that? can you have a dictionary with object values
Yeah, that works fine
#board_dict={} #for i in card_dict.keys: #board_dict[i]=card(board_dict[i][1],board_dict[i][2],board_dict[i][3],board_dict[i][4])
would a code like this work
would you like to see my program??
im making this monopoly game for fun
very early stages
board_dict={} for i in card_dict.keys(): board_dict[i]=card(board_dict[i][1],board_dict[i][2],board_dict[i][3],board_dict[i][4])
oh wait upp it shuld be card dicts for the stuff in the class parameter
board_dict={} for i in card_dict.keys(): board_dict[i]=card(card_dict[i][1],card_dict[i][2],card_dict[i][3],card_dict[i][4])
So the values of card_dict is a list?
If so that should work
its a dictionary
oh umm yes sir
its a list
Yeah, then it should work fine, sounds fun!
yeah its pretty interesting
i found a neat way to add 200 everytime someone passes go, no matter how he passes it
Just PM me if you would like any more help later on, but you seem to have got the hang of python pretty well
oh wow ya it worked!!
Join our real-time social learning platform and learn together with your friends!