I have to take ascii values from characters in a paragraph and make them print like:

116 = t = (# of times it appears)

i have everything printing right except for the number of times it appears. I don't know what I am doing wrong with this counter.

any help appreciated

Post your code with CODE tags.

text = "Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice 'without pictures or conversation?'  So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her."
    
i = 32

for x in text:
    count = 0
    while i <= 126:
        if x == chr(i):
             count += 1

        print i, "=", chr(i), "=", count
        i += 1

the 32 and 126 because im only dealing with characters in that value range from the ascii table

Print the value for "i" each time through the while() loop. And you should not use "i", "l", or "O" as single digit variable names as they can look like numbers.

for x in text:

Also the logic is bass-ackwards so print the value for "x" each time through the for() loop

for ctr in range(32, 126):
    for ltr in text:
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.