-3

Okay so I've recently started using Python and I'm not entirely sure what is wrong with this block of code. Any help would be greatly appreciated.

Edit 1: So people were asking for the actual code in text and not a picture , so here it goes:

Budget = input("What is your budget?  ")

cost_of_meal = Budget/30

print(cost_of_meal)

Error:

What is your budget?  100
Traceback (most recent call last):
  File "C:/Users/Noor/PycharmProjects/untitled/Learning.py", line 3, in <module>

    cost_for_meal = Budget/30
TypeError: unsupported operand type(s) for /: 'str' and 'int'

Process finished with exit code 1
Rushy Panchal
  • 16,979
  • 16
  • 61
  • 94
  • Please post code as **text**. An image can help to illustrate, but we need the actual code, as well as a (description of) the error output or traceback here. – Martijn Pieters May 12 '16 at 21:39
  • 1
    For what it is worth, your editor is showing you a *code style warning*. The [Python style guide](https://www.python.org/dev/peps/pep-0008/) recommends [putting spaces around a `=` in assignments](https://www.python.org/dev/peps/pep-0008/#other-recommendations). You are missing a space. – Martijn Pieters May 12 '16 at 21:39
  • Last but not least, simply hovering over that underline should display some helpful information about why it is there. – Martijn Pieters May 12 '16 at 21:44
  • oh no, that's not the error. I'm dumb when it comes to programming but I'm not that dumb, even after correcting that I was still getting errors. For further info look at the edits I just made – Mohammed Omer May 12 '16 at 21:55
  • So in future *post that information up front* so we don't have to guess. – Martijn Pieters May 12 '16 at 21:58

1 Answers1

3

You need to explicitly convert your input to an integer, because input returns a string.

Budget = int(input("What is your budget?  "))

Alternatively, if you want to convert it to a float (to support floating-point input), you want to call float() on the input.

Rushy Panchal
  • 16,979
  • 16
  • 61
  • 94