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

2
  • 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 Commented Feb 24, 2019 at 15:47
  • Note that an array in Python is not the same thing as a list. Commented Feb 24, 2019 at 16:17

1 Answer 1

1

Use list()

my_string = 'hello'
l = list(my_string)
# ['h', 'e', 'l', 'l', 'o']
Sign up to request clarification or add additional context in comments.

1 Comment

It works :) .Thank you so much

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.