Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Initialize the number
- num_init = 34789593458634198
- # Convert the number to a string
- number = str(num_init)
- # Initialize the dictionary we are going to store the count(s) in
- numbers = {}
- #Initialize the count to zero
- count = 0
- # We are going to create a for loop in order to iterate through all the values in the string.
- for substring in number:
- #Determine if the number already exists in the dict.
- if substring not in numbers:
- # If the number does not already exists in the array, initialize it to zero
- numbers[substring] = 0
- # Increment the value of the Number(s) count
- numbers[substring] += 1
- # Print the entire dictionary so we can see the counts.
- print numbers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement