After clicking please read the whole problem

So, I decided to create a Pin Generator program. The idea was that the user enters a name for example: laptop, the pin generator generates a number which is 12116201516 where 12 = l, 1 = a, 16 = p, 20 = t, 15 = o, 16 = p.

This is the table:

a = 1

b = 2

c = 3

d = 4

e = 5

f = 6

g = 7

h = 8

i = 9

j = 10

K = 11

l = 12

m = 13

n = 14

o = 15

p = 16

q = 17

r = 18

s = 19

t = 20

u = 21

v = 22

w = 23

x = 24

y = 25

z = 26

But, the problem is I am not able to write an appropriate code for it.

This is what I tried:

print('Welcome to PIN Generator!')
name = str(input('Enter a name: ')).lower
letters = a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26
while name in letters:
    print(letters)

And guess what it is I N C O R R E C T.

Please help me out!

It doesn’t know what “letter” is supposed to be. I think what you’re trying to do is what dictionaries do. Mosh has a section on dictionaries. Basically it would look like this instead:

image

It’s mapping every letter to a number using brackets “{}”.
Then for every letter in the name variable, find it in the letters variable by putting the letter in [], then print it.

The part that says “end=’’” just makes it print it all on one line.

Let me know if you get it to work or if something still doesn’t make sense!

.

print('Welcome to PIN Generator!')
name = str(input('Enter a name: ')).lower()
letters = {'a': 1, 'b': 2, 'c': 3}
for everyletter in name:
    print(letters[everyletter], end='')

Thanks for the help ur program works absolutely fine!

This project requires the code which I haven’t learned yet.

I actually didn’t reach till there :sweat_smile:

No problem. You had the right idea going though, and if you keep doing your own projects like this you’ll learn A LOT faster.

You’ll probably like lists/arrays, dictionaries, and for loops.
The one I used here is called a “for each” loop.