0

I couldnt find any solution for my problem here so ill just post it maybe someone can help me ^^

This is how the program looks like right now:

def dorkgen():

title()

kw = ['mcdonalds', 'kfc', 'doordash', 'taco bell']
param = ['oid', 'ap', 'utm_source', 'PageName', 'div', 'ID']
pageform = ['php', 'asp', 'aspx', 'htm', 'html']
    
    
    
keyword = random.choice(kw)
parameter = random.choice(param)
pageformat = random.choice(pageform)

print("\n     " + keyword + " " + "." + pageformat + "?" + parameter + "=")



anykey = input("\n     Enter any key to return to the main menu...")
mainMenu()

And I want to generate all the possible generations of kw, param, and pageform lists with custom characters inbetween if anybody can help I would really appreciate.

MusicMan24
  • 51
  • 1
  • 10
valakise
  • 3
  • 1
  • 1
    You can use this [`solution`](https://stackoverflow.com/a/798893/4985099) then concat the values. – sushanth Sep 13 '20 at 10:20

2 Answers2

1

you can just:

[f"\n    {k} =.{pf}?{prm}=" for k in kw for pf in pageform for prm in param]

It will generate a list with all of the possible combinations of those three lists.


Final code:

def dorkgen():
    title()

    kw = ['mcdonalds', 'kfc', 'doordash', 'taco bell']
    param = ['oid', 'ap', 'utm_source', 'PageName', 'div', 'ID']
    pageform = ['php', 'asp', 'aspx', 'htm', 'html']

    for ln in [f"\n    {k} =.{pf}?{prm}=" for k in kw for pf in pageform for prm in param]:
        print(ln)

    anykey = input("\n     Enter any key to return to the main menu...")
    mainMenu()
Or Y
  • 2,088
  • 3
  • 16
  • can you please tell me where should i add this line of code? im a pretty big noob and i cant figure it out where should i put it ): – valakise Sep 13 '20 at 12:10
0

You can use three for loops in a row to print all possibilities.

import random

kw = ['mcdonalds', 'kfc', 'doordash', 'taco bell']
param = ['oid', 'ap', 'utm_source', 'PageName', 'div', 'ID']
pageform = ['php', 'asp', 'aspx', 'htm', 'html']



for i in kw:
  for x in param:
    for y in pageform:
      print (i,x,y)

'''

Berat
  • 1
  • 2