Mar-06-2019, 04:54 PM
Dear brains,
So, I know this is a python forum and not VS Code forum, but I know many of you use VS code and may be able to help anyways.
when I open the following code (which is not finished - i know there's some loose ends here and there), I get the expected results: The code chooses randomly a key from the dictionary and print the "inoperation" print functions as expected.
HOWEVER, after that, when I press "play" again (without changes in the script), the exact same lines is generated. Even if I open a new script and press play it will show the same city as before. So is the problem in the code or is there a bug in the VS Code.
Have anyone tried this before?

So, I know this is a python forum and not VS Code forum, but I know many of you use VS code and may be able to help anyways.
when I open the following code (which is not finished - i know there's some loose ends here and there), I get the expected results: The code chooses randomly a key from the dictionary and print the "inoperation" print functions as expected.
HOWEVER, after that, when I press "play" again (without changes in the script), the exact same lines is generated. Even if I open a new script and press play it will show the same city as before. So is the problem in the code or is there a bug in the VS Code.
Have anyone tried this before?
import random capitals_dict = { 'Alabama': 'Montgomery', 'Alaska': 'Juneau', 'Arizona': 'Phoenix', 'Arkansas': 'Little Rock', 'California': 'Sacramento', 'Colorado': 'Denver', 'Connecticut': 'Hartford', 'Delaware': 'Dover', 'Florida': 'Tallahassee' , 'Georgia': 'Atlanta', } states = list((capitals_dict.keys())) rand_key = random.choice(states) print (rand_key) rand_key_value = capitals_dict[rand_key] phrase = ("what is the capital of ") a = 0 while a < 1 : print (phrase, rand_key) choice_user = input() if choice_user == rand_key_value: a = a + 1