You want to spell a string one by one and save it as a list

Asked 1 years ago, Updated 1 years ago, 52 views

s = "hello python!"
s.split()

If you do s.split() in the above code, it is saved as ["hello", "python!"] based on the space, right? Instead, I want to save the spelling in ['h', 'e', 'l', ..., '!'] like this, what should I do?

I used str.split(//) in Ruby, but I don't eat it in Python

python split

2022-09-21 14:20

1 Answers

Put list() on the str

s = "hello python!"
print(list(s))


2022-09-21 14:20

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.