soooo this code is supposed to generate as many fake identities as you ask for, but it never does!!
for example when I request 10 identities, I only get two, or just one sometimes, and then it just stops, i mean the code would be still running but it won't generate any more identities, it just freezes.
note: i tried to run the code on more than one computer and the same thing happens every single time.
The code:
import random
from lists import name_m, name_f, month, cars_m, to_cars, fo_cars, ho_cars
choice = input('info or {pro}gram: ')
if choice == 'pro':
gl = 0
fr_name = ''
l_name = ''
gl1 = int(input('number of people:'))
names_l = input('(M)ale , (F)emale :')
while gl < gl1:
if names_l.upper() == 'M':
fr_name = random.choice(name_m)
l_name = random.choice(name_m)
while l_name == fr_name:
fr_name = random.choice(name_m)
elif names_l.upper() == 'F':
fr_name = random.choice(name_f)
l_name = random.choice(name_m)
while l_name == fr_name:
fr_name = random.choice(name_f)
ph_num = random.sample('0123456789', 8)
bi_y = random.randint(1960, 2017)
bi_m = random.choice(month)
bi_d = random.randint(1, 28)
ex = random.randint(0, 40)
age = 2020 - bi_y
while age - 25 < ex:
ex = random.randint(0, 40)
yr = 'years'
if ex == 1:
yr = 'year'
car_co = random.choice(cars_m)
car_mo = ''
if car_co == 'Ford':
car_mo = random.choice(fo_cars)
elif car_co == 'Toyota':
car_mo = random.choice(to_cars)
elif car_co == 'Honda':
car_mo = random.choice(ho_cars)
ph_nu = f'{ph_num[0]}{ph_num[1]}{ph_num[2]}{ph_num[3]}{ph_num[4]}{ph_num[5]}{ph_num[6]}{ph_num[7]}'
email = random.choice(['gmail', 'hotmail', 'outlook'])
cho = random.sample('bcdfghjklmnpqrstvwxyz', 5)
cho_v = random.sample('aieuo', 5)
cho_n = random.sample('bcdfghjklmnpqrstvwxyz1234567890', 4)
ch = f'''{cho_n[0]}{cho_n[2]}{cho[0]}{cho_v[0]}{cho[1]}{cho_v[1]}{cho[2]}{cho_v[2]}{cho[3]}{cho_v[3]}{cho[4]}{cho_v[4]}{cho_n[2]}{cho_n[3]}'''
nu = random.randint(5, 12)
car = f'{car_co} {car_mo}'
print(f'''
Name: {fr_name} {l_name}
Birthdate: {bi_y} {bi_m} {bi_d}
Phone number: 05{ph_nu}
Email: {ch[0:nu]}@{email}.com
Experience: {ex} {yr}
Car: {car}''')
gl += 1
elif choice == 'info':
print(f'Number of male names: {len(name_m)}')
print(f'number of female names: {len(name_f)}')
print(f'Total: {len(name_f + name_m)}')
1 Answer 1
When bi_y >= 1995 then you end up with age - 25 < 0 so your while loop will never exit since ex cannot be < 0.
Change bi_y = random.randint(1960, 2017) to bi_y = random.randint(1960, 1995)
lists), which makes it harder for us to help debug. Can you condense it down to something shorter that produces the same issue that could help us debug? Have you stepped through this with a debugger to see what's wrong, or even just put in a bunch ofprintstatements to see where the code is stopping?