Issue with my code

darnold darnold992000 at yahoo.com
Tue Feb 5 16:37:03 EST 2013


On Feb 5, 2:19 pm, maiden129 <sengokubasarafe... at gmail.com> wrote:
> How to reverse the two loops?
>

s=input("Enter a string, eg(4856w23874): ")

checkS=['0','1','2','3','4','5','6','7','8','9']

for digit in checkS:
    t = s.count(digit)
    if t == 0:
        pass
    elif t == 1:
        print(digit,"occurs 1 time.")
    else:
        print(digit, "occurs", t,"times.")


>>>
Enter a string, eg(4856w23874): 23493049weee2039412367
0 occurs 2 times.
1 occurs 1 time.
2 occurs 3 times.
3 occurs 4 times.
4 occurs 3 times.
6 occurs 1 time.
7 occurs 1 time.
9 occurs 3 times.
>>>

HTH,
Don



More information about the Python-list mailing list