-1

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?

Grant Miller
  • 27,532
  • 16
  • 147
  • 165
  • Possible duplicate of [Split a string by spaces -- preserving quoted substrings -- in Python](https://stackoverflow.com/questions/79968/split-a-string-by-spaces-preserving-quoted-substrings-in-python) – Marcello B. Oct 12 '18 at 21:37
  • https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users. Please read [ask] and [mcve]. – Nic3500 Oct 13 '18 at 00:26

2 Answers2

0
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

ingvar
  • 4,169
  • 4
  • 16
  • 29
0

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