Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simplifying my code
#3
Basic simplification would be to use while loops instead of for loops, use sets instead of lists, add the random numbers to the sets directly instead of assigning them to a variable and then adding/appending, and union the two sets to find the elements of both.

If you create the two sets using list comprehensions, you could do it all in one line.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Simplifying my code - by ilondire05 - Jul-21-2019, 12:49 AM
RE: Simplifying my code - by metulburr - Jul-21-2019, 01:02 AM
RE: Simplifying my code - by ichabod801 - Jul-21-2019, 01:03 AM
RE: Simplifying my code - by metulburr - Jul-21-2019, 01:08 AM
RE: Simplifying my code - by ichabod801 - Jul-21-2019, 01:41 AM
RE: Simplifying my code - by scidam - Jul-21-2019, 03:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help for simplifying code mmk1995 8 5,691 Sep-24-2019, 02:04 PM
Last Post: perfringo
  simplifying a stack of elifs Skaperen 8 5,505 Aug-17-2019, 04:13 AM
Last Post: Skaperen
  My program subtracts fractions, but for some reason isn't simplifying them RedSkeleton007 9 7,690 Mar-03-2018, 11:45 AM
Last Post: Gribouillis
  Simplifying multiple "or" conditions in if statement. rhubarbpieguy 8 107,351 Jul-22-2017, 12:19 PM
Last Post: rhubarbpieguy

Forum Jump:

User Panel Messages

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