Mein Code so weit:.Split-String in die Räume der Wahl mit Split ("", int)
firstname = 'Christopher Arthur Hansen Brooks'.split(' ',1) # [0] selects the first element of the list
lastname = 'Christopher Arthur Hansen Brooks'.split(' ')[-1] # [-1] selects the last element of the list
print(firstname)
print(lastname)
Ich möchte Ausgang:
['Christopher Arthur Hansen', 'Brooks']
Ich möchte, dass die Ausgabe von nur die Verwendung von split(' ', int)
Methode. Wie kann ich es tun?
Sie wollen also von rechts aufteilen? Haben Sie ['rsplit'] (https://docs.python.org/3/library/stdtypes.html#str.rsplit) berücksichtigt? – jonrsharpe
Ich denke du willst ein Komma. '['Christopher Arthur Hansen', 'Brooks']' – pylang