Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 12 Online
OpenStudy (anonymous):

Hi! I'm trying to get the week 6 problem set working...am having trouble with "global variables"...with respect to the function get_words_to_points, how should I fix it so that points_dict becomes a global variable? Thanks! def get_words_to_points(word_list): points_dict={} global points_dict for word in word_list: points_dict[word]=(get_word_score(word,7)) return points_dict

OpenStudy (anonymous):

You create and change global variables this way: _ global global_variable_name # Initializing global_variable_name = 'foo' # Assignment

OpenStudy (anonymous):

why do you think you need to declare points_dict global inside of that function block?

OpenStudy (anonymous):

Also, are you sure you want to hard code the hand size as 7 in your call to get_word_score()? - is there a variable that represents hand size that you could use instead?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!