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
  problem in output of a snippet code akbarza 2 299 Feb-28-2024, 07:15 PM
Last Post: deanhystad
  My code works on Jupyter Lab/Notebook, but NOT on Visual Code Editor jst 4 871 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 439 Nov-07-2023, 04:32 PM
Last Post: snippsat
  How to set PYTHONPATH in Visual Studio Code? aupres 5 3,761 Aug-15-2023, 03:51 PM
Last Post: snippsat
  Something wrong with my code FabianPruitt 5 787 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 811 Jun-26-2023, 09:40 AM
Last Post: snippsat
  Visual Studio Code NewPi 3 985 May-16-2023, 11:13 PM
Last Post: snippsat
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,468 Mar-27-2023, 07:38 AM
Last Post: buran
  Video recording with Raspberry Pi - What´s wrong with my python code? Montezuma1502 3 1,179 Feb-24-2023, 06:14 PM
Last Post: deanhystad
  I cannot able to see output of this code ted 1 715 Feb-22-2023, 09:43 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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