Why is 25 printed first instead of apple? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why is 25 printed first instead of apple?

S = {"apple",25,"orange"} for X in S: print(X) The Output is 25 apple orange why is the integer 25 is being printed first instead of the string apple in the list

25th Sep 2020, 3:12 PM
Archana
1 Answer
+ 12
Because S is not a list, it is a set. The sets are unordered (positions of the elements are not guaranteed).
25th Sep 2020, 3:16 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar