Yes that is possible in Python 3, just use * before the variable like:

print(*list)

This will print the list separated by spaces.

(where * is the unpacking operator that turns a list into positional arguments, print(*[1,2,3]) is the same as print(1,2,3), see also What does the star operator mean, in a function call?)

Answer from Nikhil Gupta on Stack Overflow
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ python print one line list
Python Print One Line List - Be on the Right Side of Change
September 26, 2021 - To print a list and display it in a single line, a straightforward solution is to iterate over each element in a for loop and print this element into the same line using the print() function with the end=' ' argument set to the empty space.
Discussions

How can I format a list to print each element on a separate line in python? - Stack Overflow
How can I format a list to print each element on a separate line? For example I have: mylist = ['10', '12', '14'] and I wish to format the list so it prints like this: 10 12 14 so the \n, brackets, More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - How to print list value in same line? - Stack Overflow
Using the splat (*) (or unpacking ... all elements of your list as parameters to print: ... Either you make a string out of the list, either you need another loop to parse the list. There might be other solutions as well. You can use a comma after the print statement to avoid adding new line... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Printing list elements on separate lines in Python - Stack Overflow
When I try this code: import sys print sys.path I get an output like: ['.', '/usr/bin', '/home/student/Desktop', '/home/student/my_modules', '/usr/lib/pyth on2.6', '/usr/lib/python2.6/plat-linux2'... More on stackoverflow.com
๐ŸŒ stackoverflow.com
how can I print different items of a list in multiple lines?
Several others have given similar responses. Here is another take, provided that you want to be able to format the items individually when printing them: chart = [[1, 2, 3], [4, 5, 6], [7,8,9]] def print_my_chart(chart): for line in chart: for item in line: print(f"{item}\t", end='') print("") print(f"Chart before change of 5") print_my_chart(chart) chart[1][1] = 7 print(f"Chart before change of 5 to 7") print_my_chart(chart) This will print like this: Chart before change of 5 1 2 3 4 5 6 7 8 9 Chart before change of 5 to 7 1 2 3 4 7 6 7 8 9 Also, strongly avoid naming a 'list' list. 'list' is a Python keyword and results will be different than expected. More on reddit.com
๐ŸŒ r/learnpython
5
1
March 19, 2021
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ print-list-python
How to Print a List in Python: 5 Different Ways (with code)
April 13, 2023 - When you wish to print the list elements in a single line with the spaces in between, you can make use of the "*" operator for the same.
Top answer
1 of 4
1

Try join() to convert your list to string -

" ".join(map(str, li))

Here your list is a list of integers and join() joins every string element of an iterable separated by some string (in this case " "). So, you need to convert each integer to a string first. map() can do that. map() takes a function and apply it on each element of an iterable which is passes as the second arguement (here list li). So, map(str, li) will create an iterable where each element is a string representation of every element of list li

So, your line would be-

print("Case {}: {}".format(case_no, " ".join(map(str, li)), sep=' ', end=''))

You can use generator expression for that too -

print("Case {}: {}".format(case_no, " ".join(str(i) for i in li), sep=' ', end=''))

In this case you are using a generator expression (think of it like list comprehension if you don't know). The generator expresssion iterates over every element of li and returns a stringified (don't know if that's the word) version of that element.

Also, if you just want to print the list and not maintain it for other purposes then you can just simplify it a bit -

t = int(input())
for case_no in range(1, t+1):
    n = int(input())
    print("Case {}: {}".format(case_no, " ".join(str(i) for i in range(1, n+1) if not n % i), sep=' ', end=''))
2 of 4
0

You can use print to do it:

data = [[1,2,3,4], [2,4,6]]

for idx,d in enumerate(data,1):
    print( f"Case {idx}:", *d)  # "splat" the list 

prints:

Case 1: 1 2 3 4
Case 2: 2 4 6

Using the splat (*) (or unpacking argument lists) operator to provide all elements of your list as parameters to print:

print( *[1,2,3,4]) == print( 1, 2, 3, 4)
๐ŸŒ
LearnPython.com
learnpython.com โ€บ blog โ€บ python-print-list
Printing a List in Python โ€“ 10 Tips and Tricks | LearnPython.com
The newline character \n at the end of each element ensures each element will print on a separate line: ... Remember that you can use any string as a separator, not just a newline character.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ print-lists-in-python-4-different-ways
Print lists in Python - GeeksforGeeks
April 8, 2025 - Explanation: The end=' ' ensures that each element is printed on the same line separated by a space.
๐ŸŒ
Code Hunterz
codehunterz.wordpress.com โ€บ 2018 โ€บ 04 โ€บ 26 โ€บ print-list-elements-on-same-lineprint
Print List Elements on Same Line(print()) โ€“ Code Hunterz
February 15, 2019 - To print all the elements of a list on same line, we will use simple print and add one more argument in it. We will make use of end, as the last argument...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how can i print different items of a list in multiple lines?
r/learnpython on Reddit: how can I print different items of a list in multiple lines?
March 19, 2021 -

I am trying to create a chart in python using lists. I have a nested list (I think)

list = [[1, 2, 3], [4, 5, 6], [7,8,9]]

what I am trying to do is have each list in a different line so I want the output to be

1, 2, 3

4, 5, 6

7, 8, 9

so they are all in different lines and I have now created a 3x3 grid and i can access each number using its index which i think for example if I wanted to access the 5 on the middle of my chart I would do

[1][1]

row 2, position 2

(I used [1] because row 1 would be [0] and row 3 [2] (I believe))

the problem I have is that it prints it all in one single line so I am not able to create a 2d chart.

how would I create the chart using this method (or any other method sugested by you) and how would i acces each position and change its value (so for example if i wanted to access the position where the 5 currently is and turn it to a 7 so i would get

1, 2, 3

4, 7, 6

7, 8, 9

thanks.

๐ŸŒ
Quora
quora.com โ€บ How-do-you-print-a-list-and-make-each-element-appear-on-a-new-line-Python-Python-3-x-development
How to print a list and make each element appear on a new line (Python, Python 3.x, development) - Quora
Answer (1 of 2): The simple way to do this is to just splat the elements as separate arguments to the print function, with a newline as the separator between arguments: [code]>>> lst = [42, 23, 'Hello'] >>> print(*lst, sep='\n') [/code]You can also build a multiline string and then print that: ...
๐ŸŒ
Plain English
python.plainenglish.io โ€บ 3-ways-to-print-list-elements-on-separate-lines-in-python-815454bb2cd4
3 Ways to Print List Elements on Separate Lines in Python | Python in Plain English
July 16, 2024 - New Python content every day. Follow to join our 3.5M+ monthly readers. ... Dr. Ahmed Al-Jaishi ... I often want to print the elements of a list. Unfortunately, the print function packs the list elements and often makes the output unreadable(e.g., Figure 1). Below are three ways to print list elements so that each element appears on a new line.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ i'd like to print out a list in a single line, with each item separated by a space, and with a function preformed on each item in the list. i'm guess this is a complicated join. any advice on making this work?
r/learnpython on Reddit: I'd like to print out a list in a single line, with each item separated by a space, and with a function preformed on each item in the list. I'm guess this is a complicated join. Any advice on making this work?
November 12, 2022 -

I'm making a card game. I'd like to make a function that prints each card out in a single line, with a space between each card. Of course the tricky part here is the list will grow to an unknown length, and I don't want that to be an issue.

Here's what I want the printout to look like:

 ___   ___
|3  | |9  |
| โ™ฃ | | โ™ฃ |
|__3| |__9| 

I'll paste some code below that shows were my issue is. First, some context-

I'm using the objects Shoe, PlayerHand, and Card. Shoes are made of Cards. Shoe deals cards to PlayerHand.

PlayerHand.card_list and Shoe.shoe_card_list are lists of cards. Each Card stores its value (1-10, J,K,Q,A) in Card.numlet and the suit in Card.suit.

Just trust that the objects work, it's making the card_list_render work that is the issue.

Here's the code:

def card_front(card):
    """Display all the cards in the cards list."""
    print(" ___\n|{} |\n| {} |\n|_{}|".format(card.num_let.ljust(2), card.suit, card.num_let.rjust(2, '_')))

def card_list_render(hand):
    if len(hand.card_list) == 1:
        card_front(hand.card_list[0])
    else:
        return '  '.join(card_front(c) for c in hand.card_list)


test_shoe = Shoe(1)
test_hand = PlayerHand()


for card in test_shoe.shoe_card_list:
    loop_count = 1
    test_hand.card_list.append(card)
    print(f"This is loop #{loop_count}, there are {len(test_hand.card_list)} card(s) in the hand")
    card_list_render(test_hand)
    loop_count += 1

so when I run that, here is what I get:

his is loop #1, there are 1 card(s) in the hand
 ___
|5  |
| โ™ฆ |
|__5|
This is loop #1, there are 2 card(s) in the hand
 ___
|5  |
| โ™ฆ |
|__5|
 ___
|5  |
| โ™ฅ |
|__5|
Traceback (most recent call last):
  File "C:\Users\REDACTEDNAME\PycharmProjects\FINALbj\visuals.py", line 82, in <module>
    card_list_render(test_hand)
  File "C:\Users\REDACTEDNAME\PycharmProjects\FINALbj\visuals.py", line 64, in card_list_render
    return '  '.join(card_front(c) for c in hand.card_list)
TypeError: sequence item 0: expected str instance, NoneType found

I'm not sure what the issue is. So my join won't put them on the same line, and it breaks with that error. Any suggestions?

๐ŸŒ
Javatpoint
javatpoint.com โ€บ how-to-print-in-same-line-in-python
How to print in same line in Python - Javatpoint
How to print in same line in Python with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, basics, data types, operators, etc.
๐ŸŒ
AskPython
askpython.com โ€บ python โ€บ list โ€บ print-a-python-list
3 Ways to Print a List in Python [Step-by-Step] - AskPython
November 30, 2020 - ... Here, inside โ€˜ โ€˜, you can insert /n if you want to print each element of a list on the next line, or you can insert a comma(,) so that element is in one line separated by commas, or you can use any custom symbols.
๐ŸŒ
Plain English
plainenglish.io โ€บ home โ€บ blog โ€บ python โ€บ 3 ways to print list elements on separate lines in python
3 Ways to Print List Elements on Separate Lines in Python
April 11, 2022 - print("\n".join(results)) # Element number: 1, Result: 212 # Element number: 2, Result: 134 # Element number: 3, Result: 151 # Element number: 4, Result: 104 # Element number: 5, Result: 174 ยท I hope you found these code snippets helpful. Thank you for reading! ... A practical guide to the Python libraries that cover data, web APIs, testing, and automation โ€” with when to use each one.