List

I'm trying to create a list with python but i'm retarded.
List has to start with 'p4h1'
and has to be 8 characters long padded with 0 -9 and a-z in lower case
>p4h1****
how do i do it /g ?

Attached: sa.png (453x265, 38.23K)

What is that retarded neck-tie thing? Was that in original 07? Looks retarded and lacks soul

use the general threads
daily programming thread
stupid questions general

Use re.match

Sorry frien i'm new here

Attached: received_365486558880305.jpg (1027x1920, 118.33K)

i'm struggling to understand what you want. can you give us an example of the output you're expecting?

A .txt file with an output every line ex:
P4h1aaaa
P4h1aaab
Ph41aaac
...
P4h1a6h9
Until
P4h19999
Every posibility 0-9 a-z and p4h1 before

>Was that in original 07?
yes

print("test")

my nigga doesn't even know how to use nested loops
chars = "abcdefghijklmnopqrstuvwxyz0123456789"
combinations = []
s = "P4h1"
for char1 in chars:
for char2 in chars:
for char3 in chars:
for char4 in chars:
combinations.append(s+char1+char2+char3+char4)

Thank you nigger frien

Attached: 27mexican-dance1-superJumbo.jpg (1640x2048, 1.12M)

yeah broh np

watch
from string import digits, ascii_lowercase
from itertools import repeat, product

file = open("out.txt", "w")

for line in ["P4h1" + "".join(x) for x in product(*repeat(ascii_lowercase + digits, 4))]:
file.write(line)

fucking bolt ragger fuck no skill kill yourself

ok improved
from string import digits, ascii_lowercase
from itertools import repeat, product

file = open("out.txt", "w")

for suffix in product(*repeat(ascii_lowercase + digits, 4))
file.write("P4h1" + "".join(suffix) + "\n")

>*repeat
you basically just did the same thing i did but used an imperative method rather than a declaritive.
although i will admit i do not know the time complexity of itertools because i do no use it.
is it realy worth learning.

This is slower than this you dumb pythonic nigger, this is why i hate snakefags.

>slower
it's not
import time

from string import digits, ascii_lowercase
from itertools import repeat, product

t1 = time.time()

chars = "abcdefghijklmnopqrstuvwxyz0123456789"
combinations2 = []
s = "P4h1"
for char1 in chars:
for char2 in chars:
for char3 in chars:
for char4 in chars:
combinations2.append(s+char1+char2+char3+char4)

t2 = time.time()

combinations1 = []

for suffix in product(*repeat(ascii_lowercase + digits, 4)):
combinations1.append("P4h1" + "".join(suffix) + "\n")

t3 = time.time()

print("nested for loops solution: ", t2 - t1)
print("itertools solution: ", t3 - t2)
check yourself, I got:
felix ~/code/misc/gpython python main.py
nested for loops solution: 0.631260871887207
itertools solution: 0.6241495609283447
felix ~/code/misc/gpython python main.py
nested for loops solution: 0.6366860866546631
itertools solution: 0.6195902824401855
felix ~/code/misc/gpython python main.py
nested for loops solution: 0.6295139789581299
itertools solution: 0.6275153160095215

also
>pythonic nigger
>snakefag
I do Haskell in my day job
but you are a professional nigger

I didn't say anything about second solution stupid faggot, now try your first one.

In the future, you could better phrase this by mentioning that it is a list of strings. A list that starts with "p4h1" makes us think that this is the first element. But then you tell us it has to be 8 characters, and we start thinking you are talking about a string, not a list. But what you are actually talking about is the elements in the list, not the list itself.

Slower, yes, but it's easier to modify. If you suddenly need to go up to 10 characters, do you want to bring it up to 10 nested for loops? Any time you have more than 3 levels of indentation, ask yourself if you can do it in less.

>try your first one
this gets funnier and funnier
felix ~/code/misc/gpython python main.py
nested for loops solution: 0.6206271648406982
1st itertools solution: 0.5426480770111084
felix ~/code/misc/gpython python main.py
nested for loops solution: 0.6235365867614746
1st itertools solution: 0.5461874008178711
felix ~/code/misc/gpython python main.py
nested for loops solution: 0.6248588562011719
1st itertools solution: 0.5495319366455078
felix ~/code/misc/gpython python main.py
nested for loops solution: 0.6240742206573486
1st itertools solution: 0.5441904067993164
felix ~/code/misc/gpython python main.py
nested for loops solution: 0.6220088005065918
1st itertools solution: 0.542299747467041