+ 2
How do I make this output 5 names in alphabetical order?
2 Respuestas
+ 5
Change your [input()] to input().split() to split every name as each element of the list.
__________________
my_name = input()
others = input().split()
...
__________________
.split() splits the string by whitespace by default, for example:
x = "This is a string"
print(x.split())
>> ["This", "is", "a", "string"]
You can learn more about split() method here:
https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/ref_string_split.asp
https://code.sololearn.com/c5A15a3A24A2
0
import re
str = "Regular expression test"
print(re.split(" +", str))
http://net-informations.com/JUMP_LINK__&&__python__&&__JUMP_LINK/file/split.htm