+ 2

How can I print a Python set so it looks clean (no {} brackets or quotes)?

Hey! I’m working with a set in Python like this: >> fruits = {"apple", "banana", "mango"} However, whenever I print it, curly brackets and quotes appear around the words. I want the output to look like this (just plain words): apple banana mango What’s the simplest way to do this? (Bonus: What if my set contains numbers instead of strings?)

29th Jul 2025, 6:42 PM
SAIFULLAHI KHAMISU
SAIFULLAHI KHAMISU - avatar
3 Antworten
+ 6
Use the unpacking operator: print(*fruits) What output do you want to achieve for numbers?
29th Jul 2025, 7:28 PM
Lisa
Lisa - avatar
+ 4
SAIFULLAHI KHAMISU I noticed you just dumped a number of questions in the form of "How can I ... ?" I hope it doesn't become a habit. Being able to think for yourself and solve problems independently is an essential trait of a programmer. It's borderline laziness to depend on others for every little task...
30th Jul 2025, 4:10 AM
Bob_Li
Bob_Li - avatar
+ 1
You can use "join". fruits = sorted(fruits, key=None, reverse=False) fruits = ' '.join(fruits) print(fruits) https://www.sololearn.com/ru/compiler-playground/cmmPWZygqs4i/?ref=app
29th Jul 2025, 7:31 PM
Mila
Mila - avatar