Python: Split a variable length string into variables
Python Basic: Exercise-131 with Solution
Write a Python program to split a variable length string into variables.
var_list = ['a', 'b', 'c'] x, y, z = (var_list + [None] * 3)[:3] print(x, y, z) var_list = [100, 20.25] x, y = (var_list + [None] * 2)[:2] print(x, y)
a b c 100 20.25
Visualize Python code execution:
The following tool visualize what the computer is doing step-by-step as it executes the said program:
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
New Exercises:R Programming