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 942 views
1 answer 189 views
2 answers 227 views
2 answers 207 views
4 answers 329 views
...