Python Forum
How can you make it simpler?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can you make it simpler?
#4
(Aug-22-2020, 08:00 PM)bitcoin10mil Wrote: x is the first digit

num2= 2nd digit
num3= 3rd digit
num4= 4th digit
With a little change, it works with this:
def fourdigit(first):
  n = random.randint(100, 999)
  n = str(first) + str(n)
  digits = set(n)
  if(len(digits) < len(n)):
    return fourdigit(first) 
  return int(n)
rather than generating a 4 digit number it just generates a 3 digit number and adds the first digit to the front.
Reply


Messages In This Thread
How can you make it simpler? - by bitcoin10mil - Aug-22-2020, 07:21 PM
RE: How can you make it simpler? - by bitcoin10mil - Aug-22-2020, 08:00 PM
RE: How can you make it simpler? - by DreamingInsanity - Aug-22-2020, 08:15 PM
RE: How can you make it simpler? - by bowlofred - Aug-22-2020, 08:31 PM
RE: How can you make it simpler? - by snippsat - Aug-22-2020, 08:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  i am looking for a simpler tokenizer Skaperen 7 3,550 Jul-29-2019, 05:31 PM
Last Post: Skaperen
  How to make this simpler. leoahum 7 3,760 Mar-11-2019, 01:57 PM
Last Post: leoahum

Forum Jump:

User Panel Messages

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