I am fairly new to programming and have been working on a program to count the number of times every value from 0-9 occurs in a string of numbers (this program must use a function and main function that calls it). If a user enters the numbers 123512378, I want it to tell me 1 occurs 2 times 2 occurs 2 times... 8 occurs 1 time etc. Right now I am trying to pass a string into a function then return a list with the number of occurrences in order. However mine just returns the empty list I generated at the start. Here is my code:
def countdigits(aString,Result):
countValue=0
while countValue>=9:
Result[countValue]=(aString.count(str(countValue)))
countValue=countValue+1
return Result
def main():
emptyList = 10 * [0]
numbers=str(input("Pleas enter a string of numbers: "))
print(countdigits(numbers,emptyList))
main()