# Im beginner just wanted to know the error ,unless its equal to 2 the loops run,but when i enter the exact number which is 2 ,the loop does'nt end

**URL:** <https://discuss.python.org/t/im-beginner-just-wanted-to-know-the-error-unless-its-equal-to-2-the-loops-run-but-when-i-enter-the-exact-number-which-is-2-the-loop-doesnt-end/48596>\
**Category:** Python Help\
**Tags:** help\
**Created:** [March 15, 2024, 8:14am UTC](https://discuss.python.org/t/im-beginner-just-wanted-to-know-the-error-unless-its-equal-to-2-the-loops-run-but-when-i-enter-the-exact-number-which-is-2-the-loop-doesnt-end/48596 "2024-03-15T08:14:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayush\_kumar](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@ayush\_kumar](https://discuss.python.org/u/ayush_kumar)\
**Post date:** [March 15, 2024, 8:14am UTC](https://discuss.python.org/t/im-beginner-just-wanted-to-know-the-error-unless-its-equal-to-2-the-loops-run-but-when-i-enter-the-exact-number-which-is-2-the-loop-doesnt-end/48596/1 "2024-03-15T08:14:14Z")

</div>

def number(num):  
while(num != 2):  
num = input(‘enter again:’)  
else:  
print(num)

---

<div class="post-metadata">

**Author:** ![rgh](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@rgh](https://discuss.python.org/u/rgh)\
**Post date:** [March 15, 2024, 8:54am UTC](https://discuss.python.org/t/im-beginner-just-wanted-to-know-the-error-unless-its-equal-to-2-the-loops-run-but-when-i-enter-the-exact-number-which-is-2-the-loop-doesnt-end/48596/2 "2024-03-15T08:54:18Z")

</div>

input() returns a string, so if you type 2, num becomes ‘2’ (str) and not 2 (int)  
you could convert the result to an int with `int()` like this

```python
num = int(input(‘enter again:’))

```

it will raise an exception if you enter something not convertible to an int
