Python Forum
Wrong output in Visual Studio Code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wrong output in Visual Studio Code
#1
Hi Python experts,

I have started using "Visual Studio Code" and its giving little weird results.

daysInWeek={"Mon","Tues","Wed","Thur","Fri","Sat","Sun"}
for i,d in enumerate(daysInWeek):
  print(i, d)
this code is show the following results:
Output:
0 Fri 1 Wed 2 Tues 3 Thur 4 Sat 5 Sun 6 Mon
but it should be in sequence ( such as 0 Mon, 1 Tues...so on)

Any suggestions ? what could be wrong here..
Reply
#2
The result is nothing to do with visual studio code.

daysInWeek={"Mon","Tues","Wed","Thur","Fri","Sat","Sun"} is a set which is unordered.

change the {} to a tuple () or a list [] and the results will be as expected.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Visual Studio Code help aaronrousch 4 3,808 Jan-25-2025, 05:55 AM
Last Post: ndc85430
  I cannot create a virtual environment on visual studio code using python Willem_Aucamp316 2 3,306 Nov-27-2024, 02:20 PM
Last Post: menator01
  Code Completion in Visual Studio for External Libraries mjakov 0 590 Aug-25-2024, 02:48 PM
Last Post: mjakov
  problem in output of a snippet code akbarza 2 1,246 Feb-28-2024, 07:15 PM
Last Post: deanhystad
  My code works on Jupyter Lab/Notebook, but NOT on Visual Code Editor jst 4 4,252 Nov-15-2023, 06:56 PM
Last Post: jst
  I have a code which is very simple but still I cannot detect what's wrong with it max22 1 1,253 Nov-07-2023, 04:32 PM
Last Post: snippsat
  How to set PYTHONPATH in Visual Studio Code? aupres 5 12,627 Aug-15-2023, 03:51 PM
Last Post: snippsat
  Something wrong with my code FabianPruitt 5 2,022 Jul-03-2023, 10:55 PM
Last Post: Pedroski55
  how do I open two instances of visual studio code with the same folder? SuchUmami 3 4,097 Jun-26-2023, 09:40 AM
Last Post: snippsat
  Visual Studio Code NewPi 3 2,084 May-16-2023, 11:13 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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