how to use split multiple times in python code example
Example 1: split a variable into multiple variables in python
variable = "Hello, my name, is, ect"
#The seperate varibles ("a,b,c,d")
a, b, c, d = variable.split(",") # What we are splitting the variable with (",")
print(f"{a} \n {b} \n{c} \n{d}")
# Our output would be:
'''
Hello
my name
is
ect
'''
Example 2: python split multiple delimiters
#Do a str.replace('? ', ', ') and then a str.split(', ')
#Example:
a = "Hello, what is your name? I'm Bob."
a.replace('? ', ', ')
print(a)
#"Hello, what is your name, I'm Bob."
a.split(", ")
print(a)
#["Hello", "what is your name", "I'm Bob."]