Get The Most Affordable Hosting in the World!

Starting at just $1.87/month, Vercaa offers unbeatable pricing for world-class web hosting services.

Fast, reliable, and secure hosting to power your website without breaking the bank. Plus, enjoy a free CDN for faster loading times worldwide!

Get Started Now!

Since set is not a sequence data type, its items cannot be accessed individually as they do not have a positional index (as in list or tuple). Set items do not have a key either (as in dictionary) to access. You can only traverse the set items using a for loop.

Example 1

 
langs = {"C", "C++", "Java", "Python"} for lang in langs: print (lang)

It will produce the following output −

Python
C
C++
Java

Example 2

Python's membership operators let you check if a certain item is available in the set. Take a look at the following example −

 
langs = {"C", "C++", "Java", "Python"} print ("PHP" in langs) print ("Java" in langs)

It will produce the following output −

False
True



The End! should you have any inquiries, we encourage you to reach out to the Vercaa Support Center without hesitation.
War diese Antwort hilfreich? 1 Benutzer fanden dies hilfreich (1 Stimmen)