# After clicking please read the whole problem

**URL:** <https://forum.codewithmosh.com/t/after-clicking-please-read-the-whole-problem/996>\
**Category:** Python\
**Created:** [November 29, 2020, 6:33am UTC](https://forum.codewithmosh.com/t/after-clicking-please-read-the-whole-problem/996 "2020-11-29T06:33:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Megha](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/megha/32/1136_2.png) [@Megha](https://forum.codewithmosh.com/u/Megha)\
**Post date:** [November 29, 2020, 6:33am UTC](https://forum.codewithmosh.com/t/after-clicking-please-read-the-whole-problem/996/1 "2020-11-29T06:33:33Z")

</div>

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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![alex.cisija](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/alex.cisija/32/298_2.png) [@alex.cisija](https://forum.codewithmosh.com/u/alex.cisija)\
**Post date:** [November 29, 2020, 6:55am UTC](https://forum.codewithmosh.com/t/after-clicking-please-read-the-whole-problem/996/2 "2020-11-29T06:55:55Z")

</div>

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](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/9fe4ad57bb0c76473ce715c4b8acdedbe134254a.png)

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='')
```

---

<div class="post-metadata">

**Author:** ![Megha](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/megha/32/1136_2.png) [@Megha](https://forum.codewithmosh.com/u/Megha)\
**Post date:** [November 29, 2020, 8:00am UTC](https://forum.codewithmosh.com/t/after-clicking-please-read-the-whole-problem/996/3 "2020-11-29T08:00:52Z")

</div>

Thanks for the help ur program works absolutely fine!

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

> [@alex.cisija](#):
>
> I think what you’re trying to do is what dictionaries do. Mosh has a section on dictionaries.

I actually didn’t reach till there 😅

---

<div class="post-metadata">

**Author:** ![alex.cisija](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/alex.cisija/32/298_2.png) [@alex.cisija](https://forum.codewithmosh.com/u/alex.cisija)\
**Post date:** [November 29, 2020, 7:01pm UTC](https://forum.codewithmosh.com/t/after-clicking-please-read-the-whole-problem/996/4 "2020-11-29T19:01:03Z")

</div>

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.
