Python Forum
Dictionaries homework
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dictionaries homework
#8
As nilamo and Gribouillis said, you shouldn't modify the list you are looping through. It's also bad to delete from a list that was passed to a function. This will change the list outside the function, which may not be expected. To avoid having the same pair in the list twice, you should check before appending (word, rev_word) to new_lst to make sure that (rev_word, word) isn't already in new_lst.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Dictionaries homework - by pythoncrazy1 - Dec-11-2018, 03:39 PM
RE: Dictionaries homework - by Gribouillis - Dec-11-2018, 03:55 PM
RE: Dictionaries homework - by pythoncrazy1 - Dec-11-2018, 04:02 PM
RE: Dictionaries homework - by nilamo - Dec-11-2018, 08:42 PM
RE: Dictionaries homework - by ichabod801 - Dec-11-2018, 09:48 PM
RE: Dictionaries homework - by pythoncrazy1 - Dec-11-2018, 10:35 PM
RE: Dictionaries homework - by nilamo - Dec-11-2018, 10:42 PM
RE: Dictionaries homework - by ichabod801 - Dec-12-2018, 12:25 AM
RE: Dictionaries homework - by pythoncrazy1 - Dec-12-2018, 11:31 PM

Forum Jump:

User Panel Messages

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