Answers for "a tuple of integers in python"

0

how to convert tuple to int in python

# initialize tuple 
test_tuple = (1, 4, 5) 
  
# printing original tuple  
print("The original tuple : " + str(test_tuple)) 
  
# Convert Tuple to integer 
# Using int() + join() + map() 
res = int(''.join(map(str, test_tuple))) 
  
# printing result 
print("Tuple to integer conversion : " + str(res))
Posted by: Guest on July-01-2020
0

intialising a tuple in python

#Initialising an empty tuple
my_tuple = ()
#OR
my_tuple = tuple()

#Initialising elements in a tuple
my_tuple = (1,) #Single element initialization
#OR
my_tuple = (1, 2) #Multi-element initialization
#OR
my_tuple = (1, 2, "Dog") #Multi-type initialization
Posted by: Guest on January-10-2021

Code answers related to "a tuple of integers in python"

Python Answers by Framework

Browse Popular Code Answers by Language