How do you split a string into a several strings in python. The string I am trying to split is in the format of:
Variable 1
and I would like to split it into:
Variable = Variable
Number = 1
How do you split a string into a several strings in python. The string I am trying to split is in the format of:
Variable 1
and I would like to split it into:
Variable = Variable
Number = 1
You could split based on the space in the example you gave, unless you need a more generic approach.
# set up your variable
my_var = "variable 1"
# You can split by the space in this instance, if all of your data will look the same
my_split = my_var.split(" ")
# prints variable
print(my_split[0])
# prints 1
print(my_split[1])