split all letters of a word
Title
Question
How to split the string "Hello" to obtain individual alphabets?
Python-3.4.3 Getting-started-with-strings 00-01 min 0-10 sec
Answers:
list("Hello")
Yes, it is possible.
Firstly, store the word Hello into a variable as shown: s="Hello"
Secondly, use the function split as shown: print(s.split())
without split also you can do it.
In [25]: x="hello"
In [26]: x[0]
Out[26]: 'h'
In [27]: x[1]
Out[27]: 'e'
In [28]: x[2]
Out[28]: 'l'
In [29]: x[3]
Out[29]: 'l'
In [30]: x[4]
Out[30]: 'o'
In [31]: list("hello")
Out[31]: ['h', 'e', 'l', 'l', 'o']
Login to add comment
Login to add comment