w3resource

Python: Convert a list of multiple integers into a single integer

Python List: Exercise - 39 with Solution

Convert Integers List to Single Integer

Write a Python program to convert a list of multiple integers into a single integer.

Python: Convert a list of multiple integers into a single integer

Sample Solution:

Python Code:

# Define a list 'L' containing numeric elements
L = [11, 33, 50]

# Print the original list 'L'
print("Original List: ", L)

# Use the 'join' function to convert the elements of 'L' to a single string, then convert it to an integer 'x'
x = int("".join(map(str, L)))

# Print the single integer 'x'
print("Single Integer: ", x)

Sample Output:

Original List:  [11, 33, 50]                                                                                  
Single Integer:  113350

Flowchart:

Flowchart: Convert a list of multiple integers into a single integer

Python Code Editor:

Previous: Write a Python program to change the position of every n-th value with the (n+1)th in a list.
Next: Write a Python program to split a list based on first character of word.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/python-exercises/list/python-data-type-list-exercise-39.php