w3resource

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


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

For more Practice: Solve these Related Problems:

  • Write a Python program to convert a list of digits into an integer using list comprehension.
  • Write a Python program to convert a list of strings representing numbers into a single integer.
  • Write a Python program to convert a list of binary digits into its equivalent decimal integer.
  • Write a Python program to convert a list of numbers into a formatted phone number string.

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.



Follow us on Facebook and Twitter for latest update.