+ 26

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!

14th Apr 2021, 7:20 PM
Veena Tirmal
Veena Tirmal - avatar
31 Réponses
+ 24
A set is a iterable so we can use the iterable unpacking operator (*) Example: >>> a={1,2,3,4} >>> print(*a) 3 2 1 4
18th Apr 2021, 7:11 AM
Levi
Levi - avatar
+ 8
Help in the Variables in Python
23rd Nov 2021, 5:57 AM
Shubham Bhatia
Shubham Bhatia - avatar
+ 5
sets1 = {1,2,3,4,5} print(*sets1) --> 1,2,3,4,5 sets2 = {'a','b','c','d','e'} print(*sets2) --> a b c d e
27th May 2022, 7:32 AM
Surya S
Surya S - avatar
+ 1
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
14th Apr 2021, 7:59 PM
G B
G B - avatar
+ 1
A scripting language is a programming language that is interpreted. It is translated into machine code when the code is run, rather than beforehand. Scripting languages are often used for short scripts over full computer programs. JavaScript, Python, and Ruby are all examples of scripting languages.
1st Feb 2022, 7:39 AM
Abraham Zimba
Abraham Zimba - avatar
0
thisset = {"apple", "banana", "cherry"} for i in thisset: print(i) Try this. Easy way to do that
12th May 2021, 4:53 AM
Pulkit Saini
Pulkit Saini - avatar
0
Python code : s={8, 2,3,1,4} [print(s, end= " " ) for I in s] [cout << " hello World "] ; Type in the Notepad 📒with extesion (main.py)
23rd Nov 2021, 8:17 AM
Shubham Bhatia
Shubham Bhatia - avatar
0
I need some mentor here. Who can volunteer to join our whatsapp group and assist to coach people on Python with me as I am not always online and questions that need are popping in. Here is the group link https://chat.whatsapp.com/FZ25xgrgrnVGGap0cxIlHD The more you teach the more you learn. That is just a fact!
10th Mar 2022, 12:00 PM
DN Josh
DN Josh - avatar
0
Hello can anyone help me with coding I'm new
13th Mar 2022, 9:46 AM
Six Gang
0
Hey can I have some help with this I'm kinda new to this app
8th May 2022, 10:06 PM
Crystal Banyard
0
For I in range(10): printf("sorry my friend!")
15th Oct 2022, 5:37 AM
AHMAD MUSA WAZIRI
AHMAD MUSA WAZIRI - avatar
0
print (set1 & set2)
22nd Nov 2022, 4:00 PM
Adike Sidhartha rao
Adike Sidhartha rao - avatar
0
sets1 = {2,4,5,6} sets2 = {4,6,7,8,11,42,2} print(sets1 & sets2)
31st Jan 2023, 4:35 PM
Ainur Akhmet-Ganiyeva
Ainur Akhmet-Ganiyeva - avatar
0
Hi there 🙋
15th Feb 2023, 6:56 AM
Maftuna Mashrabjonova
Maftuna Mashrabjonova - avatar
0
# Take the name as input name = input() # Use concatenation to join 2 strings message = "Nice to meet you, " name # Display the message to the user print(message) I'm still a beginner and I couldn't solve this example, can you help please??
15th Jun 2023, 8:36 AM
Daniel Baranya
Daniel Baranya - avatar
22nd Jun 2023, 8:12 AM
AHMAD MUSA WAZIRI
AHMAD MUSA WAZIRI - avatar
0
i am also having trouble with this!!!
31st Jul 2023, 8:12 PM
CIANO
CIANO - avatar
0
im having trouble with that too, pls help me 😭😭😭😭😭😭😭😭😭
31st Jul 2023, 8:13 PM
MatheusAntunesBr
MatheusAntunesBr - avatar
0
print("letter")
30th Apr 2024, 5:24 PM
Vidyansh Shekhar
Vidyansh Shekhar - avatar