def isContains5(x):
    """Returns True if the given integer contains the digit 5 exactly once."""
    s = str(x)
    count5 = 0
    for c in s:
        if c == '5':
            count5 += 1
    return count5 == 1

def main():
    """How many integers from 1 to 1000 contain the digit 5 exactly once?"""
    allNumbers = ""
    count = 0
    x = 1
    while x <= 1000:
        if isContains5(x):
            allNumbers += str(x)+","
            count += 1
        x += 1
    print(allNumbers[:-1])
    print("Count: "+str(count))

if __name__ == "__main__":
    main()
