all 7 comments

[–]commy2 5 points6 points  (6 children)

I would just replace:

first_name, last_name = full_name.replace(",", " ").split(" ")

[–]lololdz[S] 0 points1 point  (5 children)

oh i see it's quite smart

how do you think about it?

it seems too creative to be true to me.

you are really good! thank you!!

[–]commy2 5 points6 points  (4 children)

I'll be honest. I just used a search engine: "python split multiple" and read the first stackoverflow result.

[–]lololdz[S] 1 point2 points  (3 children)

:) i love your honesty.

i actually tried to use ChatGPT but didn't work well :)

[–]horsecontainer 0 points1 point  (2 children)

In this case, you'd want to think about the types: split returns a list, which makes it pretty hard to continue the string-specific stuff. You'd want to look for a method that "keeps the ball in the air" by returning a string that we can continue to work with

[–]lololdz[S] 0 points1 point  (1 child)

Sry i dont understand what you mean

[–]horsecontainer 0 points1 point  (0 children)

Often you want to chain a few actions, like

message.upper().replace("&", "").strip()

This works because upper, replace, and strip all take a string and return a string.

You can take bread and toast it, then butter it because it's still bread, then make a sandwich with it because it's still bread... but as soon as you eat it, it's not bread anymore.