Python Forum
VS Code behaving strangely
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VS Code behaving strangely
#1
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?

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    
İmage
Reply


Messages In This Thread
VS Code behaving strangely - by Blaedel - Mar-06-2019, 04:54 PM
RE: VS Code behaving strangely - by Yoriz - Mar-06-2019, 07:38 PM
RE: VS Code behaving strangely - by Blaedel - Mar-06-2019, 08:06 PM
RE: VS Code behaving strangely - by Yoriz - Mar-06-2019, 08:16 PM
RE: VS Code behaving strangely - by Blaedel - Mar-06-2019, 08:29 PM
RE: VS Code behaving strangely - by Yoriz - Mar-06-2019, 08:43 PM
RE: VS Code behaving strangely - by Blaedel - Mar-06-2019, 09:07 PM
RE: VS Code behaving strangely - by Larz60+ - Mar-07-2019, 12:44 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020