Splitting a person's name into forename and surname

前端 未结 16 2014
北海茫月
北海茫月 2020-12-05 10:46

ok so basically I am asking the question of their name I want this to be one input rather than Forename and Surname.

Now is there any way of splitting this name? and

16条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 11:19

    You can use str.find() for this.

    x=input("enter your name ")
    l=x.find(" ")
    print("your first name is",x[:l])
    print("your last name is",x[l:])
    

提交回复
热议问题