I can't find a good example of the following in my textbook:
name = (input("Enter name(First Last:"))
last = name.split()
From here, I want to input the last name into another string.
How can I accomplish this task?
I can't find a good example of the following in my textbook:
name = (input("Enter name(First Last:"))
last = name.split()
From here, I want to input the last name into another string.
How can I accomplish this task?
full_name = input("Enter name (First Last):")
first_name, last_name = full_name.split()
print(first_name)
print(last_name)
Split will return 2 strings here because full_name
contains only one space between first and last name
After looking a little harder I figured out how input a variable into the middle of a string.
Here is the answer for i found for removing numbers from a string and inserting it to another string
<var0> = ''.join([i for i in <var1> if not i.isdigit()])
var0 = the string minus the numbers var1 = the initial string to be changed