Python Forum
AttributeError: module 'string' has no attribute 'uppercase'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError: module 'string' has no attribute 'uppercase'
#5
(Apr-22-2021, 04:52 PM)Anldra12 Wrote:     for word, count in freq.items():
        if is_cap(word) and word.lower() in freq:
            count = freq[word]
            freq[word.lower()] += count
            del freq[word]
You are iterating over the dictionary "freq". But then you delete an item from the dictionary. So Python does not know how to continue with the iteration. It is not allowed to change a dictionary (or list or ...) while iterating over it.
Anldra12 likes this post
Reply


Messages In This Thread
RE: AttributeError: module 'string' has no attribute 'uppercase' - by ibreeden - Apr-23-2021, 08:15 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  trouble reading string/module from excel as a list popular_dog 0 458 Oct-04-2023, 01:07 PM
Last Post: popular_dog
  getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' EarthAndMoon 4 849 Oct-03-2023, 02:00 PM
Last Post: deanhystad
  AttributeError: '_tkinter.tkapp' object has no attribute 'username' Konstantin23 4 1,881 Aug-04-2023, 12:41 PM
Last Post: Konstantin23
  Parallel processing - AttributeError: Can't get attribute 'sktimekmeans' Mohana1983 1 807 Jun-22-2023, 02:33 AM
Last Post: woooee
  Python: AttributeError: 'PageObject' object has no attribute 'extract_images' Melcu54 2 4,130 Jun-18-2023, 07:47 PM
Last Post: Melcu54
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,530 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  File "<string>", line 19, in <module> error is related to what? Frankduc 9 12,735 Mar-09-2023, 07:22 AM
Last Post: LocklearSusan
  Pandas AttributeError: 'DataFrame' object has no attribute 'concat' Sameer33 5 5,917 Feb-17-2023, 06:01 PM
Last Post: Sameer33
  AttributeError: 'numpy.ndarray' object has no attribute 'load' hobbyist 8 7,298 Jul-06-2022, 10:55 AM
Last Post: deanhystad
  AttributeError: 'numpy.int32' object has no attribute 'split' rf_kartal 6 4,562 Jun-24-2022, 08:37 AM
Last Post: Anushka00

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020