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
You create and change global variables this way: _ global global_variable_name # Initializing global_variable_name = 'foo' # Assignment
why do you think you need to declare points_dict global inside of that function block?
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?
Join our real-time social learning platform and learn together with your friends!