After the introduction of the word for counting, I'm throwing into the original line of the terminal:PS D:\Python starter essential, what's wrong?



  •     elif (vvid == 2):
            for letter in text:
                data = sorted(list(set(text.split())))  
            data[letter] = data.get(letter, 0) + 1
            print(data);
    


  • You've got a mixer in the code again.

        for letter in text:
            data = sorted(list(set(text.split())))  
    

    Why are you doing this in the cycle? Another code was:

        data = dict()  
        for letter in text:
            data[letter] = data.get(letter, 0) + 1
    

    You'll describe the complete task you need to accomplish. 'Cause now you're putting in the code pieces, but it's totally wrong:

    If you have to count the ring in the letters of a unique word, you have to do this:

    words = sorted(list(set(text.split())))
    data = dict()
    for word in words:
        for letter in word:
            data[letter] = data.get(letter, 0) + 1
    

Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2