dimanche 16 octobre 2022

Create orderer names from a certain base

I am stuck with this problem. I have to create a list of names like A0001, A0002... A0100 with all the alphabet letters. But I tried with the method random, and with some for loops, but I can not create the list with the names ["A0001"..."A0100"] it is done in python.

import numpy as np
import datetime
import re
import os
import random as rd
import string

letters = []
num = []
crias = []
numeros = []


# Crear lista del abecedario

def alphabet():
    x = list(string.ascii_uppercase)
    letters.append(x)
    return "Se han agregado las letras"


def numbers(n):
    for i in range(n + 1):
        num.append(i)
        numeros.append([str(x) for x in num])


for l in letters:
    try:
        counter = 0
        crias.append(l[counter] + numeros)
    except:
        pass

numbers(int(input("Ingrese el numero de variables de nombre (1-n)")))
alphabet()

print(crias)



Aucun commentaire:

Enregistrer un commentaire