curriculum/challenges/english/blocks/daily-coding-challenges-python/681cb1b0dab50c87ddb2e51b.md
Given an integer between 1 and 10,000, return a count of how many numbers from 1 up to that integer whose square contains at least one digit 3.
squares_with_three(1) should return 0.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(squares_with_three(1), 0)`)
}})
squares_with_three(10) should return 1.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(squares_with_three(10), 1)`)
}})
squares_with_three(100) should return 19.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(squares_with_three(100), 19)`)
}})
squares_with_three(1000) should return 326.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(squares_with_three(1000), 326)`)
}})
squares_with_three(10000) should return 4531.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(squares_with_three(10000), 4531)`)
}})
def squares_with_three(n):
return n
def squares_with_three(n):
count = 0
for i in range(1, n + 1):
square = i * i
if '3' in str(square):
count += 1
return count