0

I'm trying to split a user input string into array of characters to count the number of occurrence of each character. Below is my code

input=input()
list=input.split()
print(list)

when i input string aaasssfffgggg it gave the output ['aaasssfffgggg'] .But i need it as a array of characters

Patrick Artner
  • 48,339
  • 8
  • 43
  • 63
brean
  • 142
  • 1
  • 2
  • 11
  • I can't test rn but `list(inp)` should give the right result. Also don't name the variable `input`; you are overwriting the function – user8408080 Feb 24 '19 at 15:47
  • Note that an [`array`](https://docs.python.org/3/library/array.html) in Python is not the same thing as a `list`. – user200783 Feb 24 '19 at 16:17

1 Answers1

1

Use list()

my_string = 'hello'
l = list(my_string)
# ['h', 'e', 'l', 'l', 'o']
Community
  • 1
  • 1
molamk
  • 3,846
  • 1
  • 12
  • 22