“Unorderable types: int() < str()” Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!TypeError: unorderable types: str() > int()TypeError: unorderable types: str() > int() with listError in Python: TypeError: unorderable types: str() < int()python - battleship game - guidance needed for errorsUnorderable types str() < intError when Executing a python codeWhat is an unordaderable type?Turning a string to an integer - TypeError: '>' not supported between instances of 'str' and 'int'How to retrieve a QLabel Value as an IntegerWhat's the canonical way to check for type in Python?How do I parse a string to a float or int in Python?How to determine a Python variable's type?What are the differences between type() and isinstance()?Determine the type of an object?how to remove “TypeError: can't multiply sequence by non-int of type 'float' ”?why int object is not iterable while str is into pythonConverting str to int in PythonTypeError: Can't convert 'complex' object to str implicitly error quadratic formula function (python)python 3 getting error type error '<' not supported between instances of 'int and 'str'

Is "ein Herz wie das meine" an antiquated or colloquial use of the possesive pronoun?

Are Flameskulls resistant to magical piercing damage?

Why did Israel vote against lifting the American embargo on Cuba?

/bin/ls sorts differently than just ls

Is my guitar’s action too high?

Why are two-digit numbers in Jonathan Swift's "Gulliver's Travels" (1726) written in "German style"?

Converting a text document with special format to Pandas DataFrame

Can the van der Waals coefficients be negative in the van der Waals equation for real gases?

Why aren't road bike wheels tiny?

How do I deal with an erroneously large refund?

Is Vivien of the Wilds + Wilderness Reclamation a competitive combo?

Compiling and throwing simple dynamic exceptions at runtime for JVM

Can gravitational waves pass through a black hole?

How to produce a PS1 prompt in bash or ksh93 similar to tcsh

Construct a nonabelian group of order 44

Putting Ant-Man on house arrest

Should man-made satellites feature an intelligent inverted "cow catcher"?

A journey... into the MIND

How can I introduce the names of fantasy creatures to the reader?

Marquee sign letters

Does Prince Arnaud cause someone holding the Princess to lose?

What could prevent concentrated local exploration?

Is it OK if I do not take the receipt in Germany?

Protagonist's race is hidden - should I reveal it?



“Unorderable types: int()



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!TypeError: unorderable types: str() > int()TypeError: unorderable types: str() > int() with listError in Python: TypeError: unorderable types: str() < int()python - battleship game - guidance needed for errorsUnorderable types str() < intError when Executing a python codeWhat is an unordaderable type?Turning a string to an integer - TypeError: '>' not supported between instances of 'str' and 'int'How to retrieve a QLabel Value as an IntegerWhat's the canonical way to check for type in Python?How do I parse a string to a float or int in Python?How to determine a Python variable's type?What are the differences between type() and isinstance()?Determine the type of an object?how to remove “TypeError: can't multiply sequence by non-int of type 'float' ”?why int object is not iterable while str is into pythonConverting str to int in PythonTypeError: Can't convert 'complex' object to str implicitly error quadratic formula function (python)python 3 getting error type error '<' not supported between instances of 'int and 'str'



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








14















I'm trying to make a retirement calculator right now on Python. There's nothing wrong with the syntax but when I run the following program:



def main():
print("Let me Retire Financial Calculator")
deposit = input("Please input annual deposit in dollars: $")
rate = input ("Please input annual rate in percentage: %")
time = input("How many years until retirement?")
x = 0
value = 0
while (x < time):
x = x + 1
value = (value * rate) + deposit
print("The value of your account after" +str(time) + "years will be $" + str(value))


It tells me that:



Traceback (most recent call last):
File "/Users/myname/Documents/Let Me Retire.py", line 8, in <module>
while (x < time):
TypeError: unorderable types: int() < str()


Any ideas how I could solve this?










share|improve this question






























    14















    I'm trying to make a retirement calculator right now on Python. There's nothing wrong with the syntax but when I run the following program:



    def main():
    print("Let me Retire Financial Calculator")
    deposit = input("Please input annual deposit in dollars: $")
    rate = input ("Please input annual rate in percentage: %")
    time = input("How many years until retirement?")
    x = 0
    value = 0
    while (x < time):
    x = x + 1
    value = (value * rate) + deposit
    print("The value of your account after" +str(time) + "years will be $" + str(value))


    It tells me that:



    Traceback (most recent call last):
    File "/Users/myname/Documents/Let Me Retire.py", line 8, in <module>
    while (x < time):
    TypeError: unorderable types: int() < str()


    Any ideas how I could solve this?










    share|improve this question


























      14












      14








      14


      3






      I'm trying to make a retirement calculator right now on Python. There's nothing wrong with the syntax but when I run the following program:



      def main():
      print("Let me Retire Financial Calculator")
      deposit = input("Please input annual deposit in dollars: $")
      rate = input ("Please input annual rate in percentage: %")
      time = input("How many years until retirement?")
      x = 0
      value = 0
      while (x < time):
      x = x + 1
      value = (value * rate) + deposit
      print("The value of your account after" +str(time) + "years will be $" + str(value))


      It tells me that:



      Traceback (most recent call last):
      File "/Users/myname/Documents/Let Me Retire.py", line 8, in <module>
      while (x < time):
      TypeError: unorderable types: int() < str()


      Any ideas how I could solve this?










      share|improve this question
















      I'm trying to make a retirement calculator right now on Python. There's nothing wrong with the syntax but when I run the following program:



      def main():
      print("Let me Retire Financial Calculator")
      deposit = input("Please input annual deposit in dollars: $")
      rate = input ("Please input annual rate in percentage: %")
      time = input("How many years until retirement?")
      x = 0
      value = 0
      while (x < time):
      x = x + 1
      value = (value * rate) + deposit
      print("The value of your account after" +str(time) + "years will be $" + str(value))


      It tells me that:



      Traceback (most recent call last):
      File "/Users/myname/Documents/Let Me Retire.py", line 8, in <module>
      while (x < time):
      TypeError: unorderable types: int() < str()


      Any ideas how I could solve this?







      python calculator






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 21 '17 at 9:13









      ROMANIA_engineer

      35.1k20159147




      35.1k20159147










      asked Feb 15 '13 at 1:08









      user2074050user2074050

      76125




      76125






















          2 Answers
          2






          active

          oldest

          votes


















          33














          The issue here is that input() returns a string in Python 3.x, so when you do your comparison, you are comparing a string and an integer, which isn't well defined (what if the string is a word, how does one compare a string and a number?) - in this case Python doesn't guess, it throws an error.



          To fix this, simply call int() to convert your string to an integer:



          int(input(...))


          As a note, if you want to deal with decimal numbers, you will want to use one of float() or decimal.Decimal() (depending on your accuracy and speed needs).



          Note that the more pythonic way of looping over a series of numbers (as opposed to a while loop and counting) is to use range(). For example:



          def main():
          print("Let me Retire Financial Calculator")
          deposit = float(input("Please input annual deposit in dollars: $"))
          rate = int(input ("Please input annual rate in percentage: %")) / 100
          time = int(input("How many years until retirement?"))
          value = 0
          for x in range(1, time+1):
          value = (value * rate) + deposit
          print("The value of your account after" + str(x) + "years will be $" + str(value))





          share|improve this answer




















          • 1





            okay I figured it all out. Thank you so very much for your time and effort. I really do appreciate it. Thank you so much kind sir. There's one last issue to resolve which is that the annual rate decreases with time. For example if I input 500 dollars over 10 years at 50% rate it gives me 550 dollars after one year, 555.0, 555.55, 555.5555, etc...As in it doesn't actually do 50 percent yearly.

            – user2074050
            Feb 15 '13 at 1:22







          • 1





            @user2074050 That's just a maths error. You are adding to the deposit, not the current value. You want value *= (1 + rate) (multiply last year's value by the rate plus one).

            – Gareth Latty
            Feb 15 '13 at 2:11


















          1














          Just a side note, in Python 2.0 you could compare anything to anything (int to string). As this wasn't explicit, it was changed in 3.0, which is a good thing as you are not running into the trouble of comparing senseless values with each other or when you forget to convert a type.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14886881%2funorderable-types-int-str%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            33














            The issue here is that input() returns a string in Python 3.x, so when you do your comparison, you are comparing a string and an integer, which isn't well defined (what if the string is a word, how does one compare a string and a number?) - in this case Python doesn't guess, it throws an error.



            To fix this, simply call int() to convert your string to an integer:



            int(input(...))


            As a note, if you want to deal with decimal numbers, you will want to use one of float() or decimal.Decimal() (depending on your accuracy and speed needs).



            Note that the more pythonic way of looping over a series of numbers (as opposed to a while loop and counting) is to use range(). For example:



            def main():
            print("Let me Retire Financial Calculator")
            deposit = float(input("Please input annual deposit in dollars: $"))
            rate = int(input ("Please input annual rate in percentage: %")) / 100
            time = int(input("How many years until retirement?"))
            value = 0
            for x in range(1, time+1):
            value = (value * rate) + deposit
            print("The value of your account after" + str(x) + "years will be $" + str(value))





            share|improve this answer




















            • 1





              okay I figured it all out. Thank you so very much for your time and effort. I really do appreciate it. Thank you so much kind sir. There's one last issue to resolve which is that the annual rate decreases with time. For example if I input 500 dollars over 10 years at 50% rate it gives me 550 dollars after one year, 555.0, 555.55, 555.5555, etc...As in it doesn't actually do 50 percent yearly.

              – user2074050
              Feb 15 '13 at 1:22







            • 1





              @user2074050 That's just a maths error. You are adding to the deposit, not the current value. You want value *= (1 + rate) (multiply last year's value by the rate plus one).

              – Gareth Latty
              Feb 15 '13 at 2:11















            33














            The issue here is that input() returns a string in Python 3.x, so when you do your comparison, you are comparing a string and an integer, which isn't well defined (what if the string is a word, how does one compare a string and a number?) - in this case Python doesn't guess, it throws an error.



            To fix this, simply call int() to convert your string to an integer:



            int(input(...))


            As a note, if you want to deal with decimal numbers, you will want to use one of float() or decimal.Decimal() (depending on your accuracy and speed needs).



            Note that the more pythonic way of looping over a series of numbers (as opposed to a while loop and counting) is to use range(). For example:



            def main():
            print("Let me Retire Financial Calculator")
            deposit = float(input("Please input annual deposit in dollars: $"))
            rate = int(input ("Please input annual rate in percentage: %")) / 100
            time = int(input("How many years until retirement?"))
            value = 0
            for x in range(1, time+1):
            value = (value * rate) + deposit
            print("The value of your account after" + str(x) + "years will be $" + str(value))





            share|improve this answer




















            • 1





              okay I figured it all out. Thank you so very much for your time and effort. I really do appreciate it. Thank you so much kind sir. There's one last issue to resolve which is that the annual rate decreases with time. For example if I input 500 dollars over 10 years at 50% rate it gives me 550 dollars after one year, 555.0, 555.55, 555.5555, etc...As in it doesn't actually do 50 percent yearly.

              – user2074050
              Feb 15 '13 at 1:22







            • 1





              @user2074050 That's just a maths error. You are adding to the deposit, not the current value. You want value *= (1 + rate) (multiply last year's value by the rate plus one).

              – Gareth Latty
              Feb 15 '13 at 2:11













            33












            33








            33







            The issue here is that input() returns a string in Python 3.x, so when you do your comparison, you are comparing a string and an integer, which isn't well defined (what if the string is a word, how does one compare a string and a number?) - in this case Python doesn't guess, it throws an error.



            To fix this, simply call int() to convert your string to an integer:



            int(input(...))


            As a note, if you want to deal with decimal numbers, you will want to use one of float() or decimal.Decimal() (depending on your accuracy and speed needs).



            Note that the more pythonic way of looping over a series of numbers (as opposed to a while loop and counting) is to use range(). For example:



            def main():
            print("Let me Retire Financial Calculator")
            deposit = float(input("Please input annual deposit in dollars: $"))
            rate = int(input ("Please input annual rate in percentage: %")) / 100
            time = int(input("How many years until retirement?"))
            value = 0
            for x in range(1, time+1):
            value = (value * rate) + deposit
            print("The value of your account after" + str(x) + "years will be $" + str(value))





            share|improve this answer















            The issue here is that input() returns a string in Python 3.x, so when you do your comparison, you are comparing a string and an integer, which isn't well defined (what if the string is a word, how does one compare a string and a number?) - in this case Python doesn't guess, it throws an error.



            To fix this, simply call int() to convert your string to an integer:



            int(input(...))


            As a note, if you want to deal with decimal numbers, you will want to use one of float() or decimal.Decimal() (depending on your accuracy and speed needs).



            Note that the more pythonic way of looping over a series of numbers (as opposed to a while loop and counting) is to use range(). For example:



            def main():
            print("Let me Retire Financial Calculator")
            deposit = float(input("Please input annual deposit in dollars: $"))
            rate = int(input ("Please input annual rate in percentage: %")) / 100
            time = int(input("How many years until retirement?"))
            value = 0
            for x in range(1, time+1):
            value = (value * rate) + deposit
            print("The value of your account after" + str(x) + "years will be $" + str(value))






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 15 '13 at 1:15

























            answered Feb 15 '13 at 1:09









            Gareth LattyGareth Latty

            65.1k11129156




            65.1k11129156







            • 1





              okay I figured it all out. Thank you so very much for your time and effort. I really do appreciate it. Thank you so much kind sir. There's one last issue to resolve which is that the annual rate decreases with time. For example if I input 500 dollars over 10 years at 50% rate it gives me 550 dollars after one year, 555.0, 555.55, 555.5555, etc...As in it doesn't actually do 50 percent yearly.

              – user2074050
              Feb 15 '13 at 1:22







            • 1





              @user2074050 That's just a maths error. You are adding to the deposit, not the current value. You want value *= (1 + rate) (multiply last year's value by the rate plus one).

              – Gareth Latty
              Feb 15 '13 at 2:11












            • 1





              okay I figured it all out. Thank you so very much for your time and effort. I really do appreciate it. Thank you so much kind sir. There's one last issue to resolve which is that the annual rate decreases with time. For example if I input 500 dollars over 10 years at 50% rate it gives me 550 dollars after one year, 555.0, 555.55, 555.5555, etc...As in it doesn't actually do 50 percent yearly.

              – user2074050
              Feb 15 '13 at 1:22







            • 1





              @user2074050 That's just a maths error. You are adding to the deposit, not the current value. You want value *= (1 + rate) (multiply last year's value by the rate plus one).

              – Gareth Latty
              Feb 15 '13 at 2:11







            1




            1





            okay I figured it all out. Thank you so very much for your time and effort. I really do appreciate it. Thank you so much kind sir. There's one last issue to resolve which is that the annual rate decreases with time. For example if I input 500 dollars over 10 years at 50% rate it gives me 550 dollars after one year, 555.0, 555.55, 555.5555, etc...As in it doesn't actually do 50 percent yearly.

            – user2074050
            Feb 15 '13 at 1:22






            okay I figured it all out. Thank you so very much for your time and effort. I really do appreciate it. Thank you so much kind sir. There's one last issue to resolve which is that the annual rate decreases with time. For example if I input 500 dollars over 10 years at 50% rate it gives me 550 dollars after one year, 555.0, 555.55, 555.5555, etc...As in it doesn't actually do 50 percent yearly.

            – user2074050
            Feb 15 '13 at 1:22





            1




            1





            @user2074050 That's just a maths error. You are adding to the deposit, not the current value. You want value *= (1 + rate) (multiply last year's value by the rate plus one).

            – Gareth Latty
            Feb 15 '13 at 2:11





            @user2074050 That's just a maths error. You are adding to the deposit, not the current value. You want value *= (1 + rate) (multiply last year's value by the rate plus one).

            – Gareth Latty
            Feb 15 '13 at 2:11













            1














            Just a side note, in Python 2.0 you could compare anything to anything (int to string). As this wasn't explicit, it was changed in 3.0, which is a good thing as you are not running into the trouble of comparing senseless values with each other or when you forget to convert a type.






            share|improve this answer



























              1














              Just a side note, in Python 2.0 you could compare anything to anything (int to string). As this wasn't explicit, it was changed in 3.0, which is a good thing as you are not running into the trouble of comparing senseless values with each other or when you forget to convert a type.






              share|improve this answer

























                1












                1








                1







                Just a side note, in Python 2.0 you could compare anything to anything (int to string). As this wasn't explicit, it was changed in 3.0, which is a good thing as you are not running into the trouble of comparing senseless values with each other or when you forget to convert a type.






                share|improve this answer













                Just a side note, in Python 2.0 you could compare anything to anything (int to string). As this wasn't explicit, it was changed in 3.0, which is a good thing as you are not running into the trouble of comparing senseless values with each other or when you forget to convert a type.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jun 26 '17 at 21:29









                user1767754user1767754

                10.5k57487




                10.5k57487



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14886881%2funorderable-types-int-str%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved