Week 13: Sum of basics

posted Jan 27, 2017, 7:58 AM by Attila Lengyel
y = 0
z = 0

digit = input("Give me a digit:")
digits = int(input("How many digits:"))

for x in range(10**(digits-1), 10**(digits)):
  if str(x).count(digit) > 0:
    y = y + 1
  z = z + str(x).count(digit)
  
print("Number of found:", y)
print("Total", digit, "s:", z)
Comments