Sets python | Sololearn: Learn to code for FREE!

+14

Sets python

Is it possible to print a set in an easy way without brackets & double quotes. I'm seeing a lot of YouTube videos but all of them end up at creating a class and object to do that. Any idea of how to do that. Please no hate comments!

4/14/2021 7:20:28 PM

Veena Tirmal

18 Answers

New Answer

+5

s={8,2,4,1,3,7} [print(i,end=" ") for i in s]

+2

Or in python: st = {1,2,2,3,3,4,5,6} #1. print(' '.join([str(m) for m in st])) #2. for m in st: print(m, end=' ') #Both 1 and 2 will print 1 2 3 4 5

+2

A set is a iterable so we can use the iterable unpacking operator (*) Example: >>> a={1,2,3,4} >>> print(*a) 1 2 3 4

+1

thisset = {"apple", "banana", "cherry"} for i in thisset: print(i) Try this. Easy way to do that

0

Guys can anyone help me who to code in python culcaulan

0

Sp (9,7,5,3,1) Document Script ("Hello print"!);

0

ง่ายมาก

-1

I do it this way: var a:Set<Int> = setOf(1,2,3) a.forEach { print("$it ")} // will print: 1 2 3

-1

That just the logic curly braces must be use, else that's not a Set.

-1

-1

Phython server laptop kon sa install kiya jayega

-1

-2

-2

-2

-2

-3

Có ai viet năm ko

-4