how could i count the 4 in an integer with python.
The integer is 3 to the 10000. And I would like to know how often is the 4 in this integer.
maybe something like: count 4 in 3**10000
how could i count the 4 in an integer with python.
The integer is 3 to the 10000. And I would like to know how often is the 4 in this integer.
maybe something like: count 4 in 3**10000
The following works:
len(str(3**10000).split('4'))-1
or as suggested below:
str(3**10000).count('4')
both give 495.