I'm looking for a list of 2 letters and then 2 numbers. Something like:
aa00
aa01
aa02
aa03
aa04
ect.
I am using this for a Python program that picks a random 4 digit number, a random 4 letter string, and a random 2 letter 2 number string.
I tried combining half of the first two, but it said that it could not add 'int' and 'str' objects
. I couldn't convert the numbers to a string
, because they are used for a mathematical equation later in the program.
You can turn the number into a string just for the concatenation:
result = letters + str(number)
But if you want to have the numbers 0 through to 9 work too you probably want to zero-pad the number. You could use string formatting here, using str.format()
:
result = '{}{:02d}'.format(letters, number)
Both approaches leave the number
variable untouched; it is still referencing a number.