# Beginner with python, having issues with my super simple code

**URL:** <https://forum.freecodecamp.org/t/beginner-with-python-having-issues-with-my-super-simple-code/348118>\
**Category:** General\
**Created:** [February 7, 2020, 2:30am UTC](https://forum.freecodecamp.org/t/beginner-with-python-having-issues-with-my-super-simple-code/348118 "2020-02-07T02:30:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ldahill](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@ldahill](https://forum.freecodecamp.org/u/ldahill)\
**Post date:** [February 7, 2020, 2:30am UTC](https://forum.freecodecamp.org/t/beginner-with-python-having-issues-with-my-super-simple-code/348118/1 "2020-02-07T02:30:23Z")

</div>

So I’m new to Python. I have a little experience with visual basic, and I was told that Python is actually much easier. I’m making a simple dice gambling game as my first code, but for some reason in netbeans, I have no problem with the code, but when I try to compile it, I keep getting an error. Here is the code:

```auto
import random
import sys
pmoney = 500

roll = "yes"
while roll == "yes":
    if roll == "no":
        sys.exit()
    if pmoney < 1:
        sys.exit("You ran out of money")
    pbet = input("How much do you want to bet? ")
    if pbet > pmoney:
        pbet = input("You don't have that much, try again. ")
    npmoney = (pmoney - pbet)
    intdroll = random.randint(1,2)
    intpnum = input("Choose a number between 1 and 2 ")
    if intpnum == intdroll:
        print("YOU WIN!")
        pmoney = (pbet * 2) + npmoney
        print("You have %d" %pmoney)
    elif intpnum != intdroll:
        print("YOU LOSE!")
        pmoney = (pmoney - pbet)
        print("You have %d" %pmoney)
    roll = raw_input("Roll again? ")

```

When I try to compile it, it keeps telling me that either pbet or pmoney is a string. My brother is a software engineer and knows python pretty well. He says for some reason something is forcing my variable pbet to be a string, and he said I can force it into an integer by doing pbet = int(input()) but he said he’s not sure why I would have to do that. Any ideas would be greatly appreciated.

UPDATE:  
Apparently, you have to specify integers when using the input command. Also had to change the raw\_input on my last line of code as well to just input.

---

<div class="post-metadata">

**Author:** ![robertgroves](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/robertgroves/32/209852_2.png) [@robertgroves](https://forum.freecodecamp.org/u/robertgroves)\
**Post date:** [February 7, 2020, 4:10am UTC](https://forum.freecodecamp.org/t/beginner-with-python-having-issues-with-my-super-simple-code/348118/2 "2020-02-07T04:10:09Z")

</div>

Hi @ldahill, welcome to the freeCodeCamp forum!

You may now realize this, but whenever you use the [input built-in function](https://docs.python.org/3.3/library/functions.html?highlight=input%20function#input) to get input from the user, that function takes what the user typed in and returns it as a string value, even if they only typed in a number.

Wrapping the `input` function call within a call to the [`int` built-in function](https://docs.python.org/3.3/library/functions.html?highlight=input%20function#int) will convert the string value that `input` returns and convert it to an integer value.

So this:

```auto
userInt = int(input('Enter a number: '))

```

Would give essentially the same result as performing the two calls separately:

```auto
userStr = input('Enter a number: ')
userInt = int(userStr)

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 7:36pm UTC](https://forum.freecodecamp.org/t/beginner-with-python-having-issues-with-my-super-simple-code/348118/3 "2021-06-01T19:36:51Z")

</div>

Closed on June 1, 2021, 7:36pm UTC


