Python Forum
Wrong output in Visual Studio Code - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Wrong output in Visual Studio Code (/thread-19360.html)



Wrong output in Visual Studio Code - py_learner - Jun-24-2019

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..


RE: Wrong output in Visual Studio Code - Yoriz - Jun-24-2019

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.