Jump to content

DMentMan

Members
  • Content Count

    1655
  • Joined

  • Last visited

Posts posted by DMentMan


  1. 1 hour ago, kichilron said:

    One question:

    why do you convert from int to string on the money-variable?

    A friend told me to do it and I just left it like that =D   I'll try to redo it with the info you provided in mind =)

    30 minutes ago, DannyDog said:

    To be more specific @dmentman he meant just convert Money to an integer using int(Money) and NOT str(int(Money))

     Replacing str(int(Money)) with int(Money) gives an error =/

     

     

    Thanks guys, I'll let ya know if it works =D


  2. Hello, I only recently got into coding in Python and I've got a problem I can't solve so I hope someone might be able to help me here. =D

    I want my simple piece of code to say that if you have over 8000 it responds with that you can pay the rent. If you have under 8000 I want it to respond with that you can't pay the rent.

    I've pretty much got it working after a few issues being fixed, but if the input is 30 it says I can't pay the rent for some reason... Anyways here is the code, and thanks for any feedback or help =D

    (And yes I know like 5 and 7 are not needed, but they fixed some problems when I put 10000 as the input it said I can't afford to pay the rent for some reason =P)

     

    def Money():
      Money = input("How much money do you have?")
      str(int(Money))
      if Money > "8000":
        print("You can pay the rent!")
      elif Money > "10000":
        print("You can pay the rent!")
      elif Money == "10000":
        print("You can pay the rent!")
      elif Money == "8000":
        print("You can pay the rent!")
       elif Money < "8000":
        print("You can't afford to pay the rent!")
      else:
        print("Error")
    Money()

    def exit1():
    #Exits program after question has been answered

     exit1()

    exit()

×