How to create initialize and print a set in Python

3 Answers

0 votes
st = {"python", "c++", "java", "java", "php", "php"}

print(st)

'''
run:

{'php', 'python', 'java', 'c++'}

'''

 



answered Sep 15, 2018 by avibootz
0 votes
s = set(["python", "c++", "java", "php", "c"])

print(s)

'''
run:

{'java', 'python', 'c++', 'c', 'php'}

'''

 



answered Sep 15, 2018 by avibootz
0 votes
st = {"python", "c++", "java", "java", "php", "php"}

for item in st:
    print(item)


'''
run:

php
c++
java
python

'''

 



answered Sep 15, 2018 by avibootz

Related questions

1 answer 934 views
1 answer 177 views
2 answers 210 views
2 answers 196 views
4 answers 308 views
...