0

I have a string (down below) and I am asked to write code so it only prints out the name

s = "jimmy.clancy5@mail.ucd.ie"

output =" Jimmy Clancy"

my code below splits the string into tokens the first name is correct but for the second it also prints 5@mail I'm not exactly sure how to remove it

    import sys
    input = sys.stdin.readlines()

    for name in input:
        name = name.strip().split(".")
        second_name = name[1]
Lucas
  • 6,869
  • 5
  • 29
  • 44
notmynuts
  • 3
  • 3
  • 2
    Does this answer your question? [Removing numbers from string](https://stackoverflow.com/questions/12851791/removing-numbers-from-string) – politinsa Apr 30 '21 at 12:06

1 Answers1

0

assuming that complete name is present before @ and first name, last name is separated by . than following code will work for you

   s = "jimmy.clancy5@mail.ucd.ie"
    name = s.split("@")[0]
    fname , lastname = name.split(".")
Muhammad Safwan
  • 869
  • 7
  • 12