+ 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!
31 Respuestas
+ 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
+ 8
Help in the Variables in Python
+ 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
+ 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
+ 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.
0
thisset = {"apple", "banana", "cherry"}
for i in thisset:
print(i)
Try this. Easy way to do that
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)
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!
0
Hello can anyone help me with coding I'm new
0
Hey can I have some help with this I'm kinda new to this app
0
https://www.sololearn.com/discuss/3036158/?ref=app
https://www.sololearn.com/discuss/3035887/?ref=app
https://www.sololearn.com/discuss/3035548/?ref=app
https://www.sololearn.com/discuss/3035610/?ref=app
https://www.sololearn.com/discuss/3035739/?ref=app
https://www.sololearn.com/discuss/3035624/?ref=app
https://www.sololearn.com/discuss/3035752/?ref=app
https://www.sololearn.com/discuss/3036009/?ref=app
https://www.sololearn.com/discuss/3035538/?ref=app
https://www.sololearn.com/discuss/3035824/?ref=app
0
For I in range(10):
printf("sorry my friend!")
0
print (set1 & set2)
0
sets1 = {2,4,5,6}
sets2 = {4,6,7,8,11,42,2}
print(sets1 & sets2)
0
Hi there 🙋
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??
0
i am also having trouble with this!!!
0
im having trouble with that too, pls help me 😭😭😭😭😭😭😭😭😭
0
print("letter")