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.
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:
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.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics