0
Needs some help with python
i d like to input a random word and get an output of this word with its characters in a list. for ex. input hello and get (h, e, l, l, o)
2 Réponses
+ 1
You could use a list comprehension.
word = input()
alist = [i for i in word]
print(alist)
or
word = input()
alist = []
for char in word:
alist.append(char)
print(alist)
Also ('h', 'e', 'l', 'l', 'o') is a tuple. List has square brackets and is mutable.
+ 1
thank you