so as a task I've been asked to create a bin number generator in python where if the user inputs a code template the program has to print out a series of bin numbers. The user must input the code template using the follwing characters n = level range, z = special character(either - or /), s = stack number, c = character. For example, if the user has this as the code template "nnzcczss", z = -, level range = from 1 to 5, and stack number = from 1 to 5. The output should be: 01-AA-01 01-AA-02 01-AA-03 01-AA-04 01-AA-05 02-AA-01 02-AA-02 ... and so on.
so far here is what I have as my code:
import re
# C = code template
# Z = special character
# N = level range
# S = stack number
code_template = list(input("Enter code template: "))
special_char = input("Enter special character: ")
level_range = input("Enter level number range: ")
stack_char = input("Enter stack numbers: ")
ct = []
# storing stuff in lists
numidentify1 = [int(num) for num in level_range.split() if num.isdigit()]
lvlrangelist = list(range(numidentify1[0], numidentify1[1] + 1))
numidentify2 = [int(num1) for num1 in stack_char.split() if num1.isdigit()]
stc_chrlist = list(range(numidentify2[0], numidentify2[1] + 1))
# for loops to iterate over and print
for x in code_template:
new_template = ['A' if x == 'c' else x for x in code_template]
new_template = [special_char if x == 'z' else x for x in code_template]
for i in range(len(lvlrangelist)):
new_template = [lvlrangelist[i] if x == 'n' else x for x in code_template]
for j in range(len(stc_chrlist)):
new_template = [stc_chrlist[j] if x == 's' else x for x in code_template]
print(new_template)
However my outputs always come as:
['n', 'n', 'z', 'c', 'c', 'z', 1, 1]
['n', 'n', 'z', 'c', 'c', 'z', 2, 2]
I am not able to replace the letters with the numbers needed any idea on how I should go about this?