Skip to content

Python print tuple values | Example code

Simply pass the tuple into the print function to print tuple values. It will print the exact tuple but if you want to print it with string then convert it to string.

Print value from a tuple in python

Simple python example code creates and prints the tuple.

mytuple = ('A', 'B', 'C', 'D', 'E', 'F', 'G')

print(mytuple)

Output:

Python print tuple values

Want to return a specific value from the tuple

To get the first and second elements from tuples.

mytuple = ('A', 'B', 'C', 'D', 'E', 'F', 'G')

# First value
print(mytuple[0])

# Second value
print(mytuple[1])

Output:

A
B

Get the element from 1 to 2 index values, it actually slicing a tuple.

mytuple = ('A', 'B', 'C', 'D', 'E', 'F', 'G')

print(mytuple[1:3])

Output: (‘B’, ‘C’)

Printing tuple with string formatting in Python

Simple way use str method to print tuple with string.

tup = (1, 2, 3)

print("This is a tuple : " + str(tup))

Output: This is a tuple : (1, 2, 3)

How to print a list of tuples with no brackets in Python?

To print each item in your list of tuples, just do:

mytuple = ('A', 'B', 'C')

for item in mytuple:
    print(str(item[0]))

Output:

A
B
C

In one line

mytuple = ('A', 'B', 'C')

print(','.join([str(i[0]) for i in mytuple]))

Output: A,B,C

Do comment if you have any doubts and suggestions on this Python tuple code.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

2 thoughts on “Python print tuple values | Example code”

  1. Hi Rohit,
    Can you please explain the part which is to print the tuple in the same line:
    mytuple = (‘A’, ‘B’, ‘C’)
    print(‘,’.join([str(i[0]) for i in mytuple])
    I get the overview, but I wanted to know is there a way we can simplify it, or may be without using list comprehension

    Many Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *