Python - TypeError: can't multiply sequence by non-int of type 'str'











up vote
0
down vote

favorite












This is my code for a school project (I am writing this in Python 2.7.13):



def euconverter(mon, rate):
return (mon * rate)

cur = raw_input('Please give me the currency')
mon = raw_input('Please give me the value')
rate = raw_input('Please give me the rate')
while cur == 'EUR' or cur == 'Eur' or cur == 'GBP' or cur == 'Gbp':
if cur == 'Eur' or cur == 'Eur':
print (euconverter(mon, rate))
elif cur == 'GBP' or cur == 'Gbp':
print (euconverter(mon, rate))
else:
if cur != 'EUR' or cur != 'Eur' or cur != 'GBP' or cur != 'Gbp':
print 'Wrong input'
break


I get this error:



Traceback (most recent call last):
File "C:/Users/Maple/PycharmProjects/untitled/Mid term Project.py", line 15, in <module>
print (euconverter(mon, rate))
File "C:/Users/Maple/PycharmProjects/untitled/Mid term Project.py", line 2, in euconverter
return int(mon * rate)
TypeError: can't multiply sequence by non-int of type 'str'


Also, if I type a numeric value when it is asking me for the currency type, then the program exits without displaying any messages.
This is a school project, so I am expecting to get wrong inputs from the users and need to provide them with the required error message while trying to make them go back and input the correct one.










share|improve this question




















  • 1




    mon and rate are strings. You need to convert them to numbers.
    – khelwood
    Nov 9 at 9:02










  • Possible duplicate of How do I do simple user input in python?
    – khelwood
    Nov 9 at 9:03










  • Also your while is an infinite loop, because you don't read a new value for cur inside it.
    – khelwood
    Nov 9 at 9:05










  • @khelwood part of the answer is the same, yes but the question also asks about catching input errors
    – Scott Anderson
    Nov 9 at 9:06










  • @ScottAnderson Yes, but I can't also vote for "too broad".
    – khelwood
    Nov 9 at 9:08















up vote
0
down vote

favorite












This is my code for a school project (I am writing this in Python 2.7.13):



def euconverter(mon, rate):
return (mon * rate)

cur = raw_input('Please give me the currency')
mon = raw_input('Please give me the value')
rate = raw_input('Please give me the rate')
while cur == 'EUR' or cur == 'Eur' or cur == 'GBP' or cur == 'Gbp':
if cur == 'Eur' or cur == 'Eur':
print (euconverter(mon, rate))
elif cur == 'GBP' or cur == 'Gbp':
print (euconverter(mon, rate))
else:
if cur != 'EUR' or cur != 'Eur' or cur != 'GBP' or cur != 'Gbp':
print 'Wrong input'
break


I get this error:



Traceback (most recent call last):
File "C:/Users/Maple/PycharmProjects/untitled/Mid term Project.py", line 15, in <module>
print (euconverter(mon, rate))
File "C:/Users/Maple/PycharmProjects/untitled/Mid term Project.py", line 2, in euconverter
return int(mon * rate)
TypeError: can't multiply sequence by non-int of type 'str'


Also, if I type a numeric value when it is asking me for the currency type, then the program exits without displaying any messages.
This is a school project, so I am expecting to get wrong inputs from the users and need to provide them with the required error message while trying to make them go back and input the correct one.










share|improve this question




















  • 1




    mon and rate are strings. You need to convert them to numbers.
    – khelwood
    Nov 9 at 9:02










  • Possible duplicate of How do I do simple user input in python?
    – khelwood
    Nov 9 at 9:03










  • Also your while is an infinite loop, because you don't read a new value for cur inside it.
    – khelwood
    Nov 9 at 9:05










  • @khelwood part of the answer is the same, yes but the question also asks about catching input errors
    – Scott Anderson
    Nov 9 at 9:06










  • @ScottAnderson Yes, but I can't also vote for "too broad".
    – khelwood
    Nov 9 at 9:08













up vote
0
down vote

favorite









up vote
0
down vote

favorite











This is my code for a school project (I am writing this in Python 2.7.13):



def euconverter(mon, rate):
return (mon * rate)

cur = raw_input('Please give me the currency')
mon = raw_input('Please give me the value')
rate = raw_input('Please give me the rate')
while cur == 'EUR' or cur == 'Eur' or cur == 'GBP' or cur == 'Gbp':
if cur == 'Eur' or cur == 'Eur':
print (euconverter(mon, rate))
elif cur == 'GBP' or cur == 'Gbp':
print (euconverter(mon, rate))
else:
if cur != 'EUR' or cur != 'Eur' or cur != 'GBP' or cur != 'Gbp':
print 'Wrong input'
break


I get this error:



Traceback (most recent call last):
File "C:/Users/Maple/PycharmProjects/untitled/Mid term Project.py", line 15, in <module>
print (euconverter(mon, rate))
File "C:/Users/Maple/PycharmProjects/untitled/Mid term Project.py", line 2, in euconverter
return int(mon * rate)
TypeError: can't multiply sequence by non-int of type 'str'


Also, if I type a numeric value when it is asking me for the currency type, then the program exits without displaying any messages.
This is a school project, so I am expecting to get wrong inputs from the users and need to provide them with the required error message while trying to make them go back and input the correct one.










share|improve this question















This is my code for a school project (I am writing this in Python 2.7.13):



def euconverter(mon, rate):
return (mon * rate)

cur = raw_input('Please give me the currency')
mon = raw_input('Please give me the value')
rate = raw_input('Please give me the rate')
while cur == 'EUR' or cur == 'Eur' or cur == 'GBP' or cur == 'Gbp':
if cur == 'Eur' or cur == 'Eur':
print (euconverter(mon, rate))
elif cur == 'GBP' or cur == 'Gbp':
print (euconverter(mon, rate))
else:
if cur != 'EUR' or cur != 'Eur' or cur != 'GBP' or cur != 'Gbp':
print 'Wrong input'
break


I get this error:



Traceback (most recent call last):
File "C:/Users/Maple/PycharmProjects/untitled/Mid term Project.py", line 15, in <module>
print (euconverter(mon, rate))
File "C:/Users/Maple/PycharmProjects/untitled/Mid term Project.py", line 2, in euconverter
return int(mon * rate)
TypeError: can't multiply sequence by non-int of type 'str'


Also, if I type a numeric value when it is asking me for the currency type, then the program exits without displaying any messages.
This is a school project, so I am expecting to get wrong inputs from the users and need to provide them with the required error message while trying to make them go back and input the correct one.







python python-2.7






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 9:53









Ralf

4,4164833




4,4164833










asked Nov 9 at 9:00









Maple Sapling

1




1








  • 1




    mon and rate are strings. You need to convert them to numbers.
    – khelwood
    Nov 9 at 9:02










  • Possible duplicate of How do I do simple user input in python?
    – khelwood
    Nov 9 at 9:03










  • Also your while is an infinite loop, because you don't read a new value for cur inside it.
    – khelwood
    Nov 9 at 9:05










  • @khelwood part of the answer is the same, yes but the question also asks about catching input errors
    – Scott Anderson
    Nov 9 at 9:06










  • @ScottAnderson Yes, but I can't also vote for "too broad".
    – khelwood
    Nov 9 at 9:08














  • 1




    mon and rate are strings. You need to convert them to numbers.
    – khelwood
    Nov 9 at 9:02










  • Possible duplicate of How do I do simple user input in python?
    – khelwood
    Nov 9 at 9:03










  • Also your while is an infinite loop, because you don't read a new value for cur inside it.
    – khelwood
    Nov 9 at 9:05










  • @khelwood part of the answer is the same, yes but the question also asks about catching input errors
    – Scott Anderson
    Nov 9 at 9:06










  • @ScottAnderson Yes, but I can't also vote for "too broad".
    – khelwood
    Nov 9 at 9:08








1




1




mon and rate are strings. You need to convert them to numbers.
– khelwood
Nov 9 at 9:02




mon and rate are strings. You need to convert them to numbers.
– khelwood
Nov 9 at 9:02












Possible duplicate of How do I do simple user input in python?
– khelwood
Nov 9 at 9:03




Possible duplicate of How do I do simple user input in python?
– khelwood
Nov 9 at 9:03












Also your while is an infinite loop, because you don't read a new value for cur inside it.
– khelwood
Nov 9 at 9:05




Also your while is an infinite loop, because you don't read a new value for cur inside it.
– khelwood
Nov 9 at 9:05












@khelwood part of the answer is the same, yes but the question also asks about catching input errors
– Scott Anderson
Nov 9 at 9:06




@khelwood part of the answer is the same, yes but the question also asks about catching input errors
– Scott Anderson
Nov 9 at 9:06












@ScottAnderson Yes, but I can't also vote for "too broad".
– khelwood
Nov 9 at 9:08




@ScottAnderson Yes, but I can't also vote for "too broad".
– khelwood
Nov 9 at 9:08












4 Answers
4






active

oldest

votes

















up vote
0
down vote













As mentioned in comments, mon and raw are implicitly strings.
To convert them, use e.g. mon = int(mon) or mon = float(mon).



Be careful tho, as you should take care of invalid input (try - except TypeError block).



Few tips:
- Last if should use and instead of or
- there is no difference between these two lines:



if cur == 'Eur' or cur == 'Eur':
print (euconverter(mon, rate))
elif cur == 'GBP' or cur == 'Gbp':
print (euconverter(mon, rate))


you can group them together, if this is intentional






share|improve this answer




























    up vote
    0
    down vote













    Some refactored code for your text input would look like:



    legal_input = ["gbp", "eur", "yen"]
    currency = raw_input("Please enter the currency type")
    if currency.lower() in legal_input:
    #some code to do the required operations
    else:
    print('not a recognised currency type!')





    share|improve this answer





















    • We aren't taught how to use legal input therefore i cannot add it to a project :/
      – Maple Sapling
      Nov 9 at 9:28










    • Ok well read my comment on the question as to why your while loop stops you from catching any input errors
      – Scott Anderson
      Nov 9 at 10:02


















    up vote
    0
    down vote













    It seems that what you are trying to do is to prompt the user for input and validate it, and then ask again if it is not valid.
    You can try that by wrapping each raw_input() inside a while-loop with a flag.



    To validate the currency it would be easier to cast the input to uppercase and then check agains a list of allowed possibilities.



    To validate the amount and rate, you could cast them to float inside a try-except block.



    valid_currencies = ['EUR', 'GBP']
    cur = None
    mon = None
    rate = None

    is_valid = False
    while not is_valid:
    cur = raw_input('Please give me the currency').upper()
    if cur in valid_currencies:
    is_valid = True
    else:
    print 'Not a valid currency'

    is_valid = False
    while not is_valid:
    try:
    mon = float(raw_input('Please give me the value'))
    is_valid = True
    except ValueError:
    print 'Not a valid value'

    is_valid = False
    while not is_valid:
    try:
    rate = float(raw_input('Please give me the rate'))
    is_valid = True
    except ValueError:
    print 'Not a valid rate'

    print 'Converted amount'
    print mon * rate





    share|improve this answer




























      up vote
      0
      down vote













      def euconverter(mon, rate):
      return mon * rate


      cur = raw_input('Please give me the currency type ')
      mon = float(raw_input('Please give me the ammount of money '))
      rate = float(raw_input('Please give me the rate of the exchange '))
      while True:
      #i dont know how to make the false statement ending the program as well not necessary i think
      if cur == 'EUR' or cur == 'Eur' or cur == 'GBP' or cur == 'Gbp':
      if cur == 'EUR' or cur == 'Eur':
      print (euconverter(mon, rate))
      break
      elif cur == 'GBP' or cur == 'Gbp':
      print (euconverter(mon, rate))
      break
      # I dont know if multiple breaks should be included here
      else:
      print 'wrong input'
      cur = raw_input('Please give me the currency type again correcntly this time ')
      continue


      With tips and help from everyone i finally got it running prompting the user to enter an other currency in the currency input line when wrong appreciate your help you'll be hearing from me soon again xD






      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',
        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%2f53222599%2fpython-typeerror-cant-multiply-sequence-by-non-int-of-type-str%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        0
        down vote













        As mentioned in comments, mon and raw are implicitly strings.
        To convert them, use e.g. mon = int(mon) or mon = float(mon).



        Be careful tho, as you should take care of invalid input (try - except TypeError block).



        Few tips:
        - Last if should use and instead of or
        - there is no difference between these two lines:



        if cur == 'Eur' or cur == 'Eur':
        print (euconverter(mon, rate))
        elif cur == 'GBP' or cur == 'Gbp':
        print (euconverter(mon, rate))


        you can group them together, if this is intentional






        share|improve this answer

























          up vote
          0
          down vote













          As mentioned in comments, mon and raw are implicitly strings.
          To convert them, use e.g. mon = int(mon) or mon = float(mon).



          Be careful tho, as you should take care of invalid input (try - except TypeError block).



          Few tips:
          - Last if should use and instead of or
          - there is no difference between these two lines:



          if cur == 'Eur' or cur == 'Eur':
          print (euconverter(mon, rate))
          elif cur == 'GBP' or cur == 'Gbp':
          print (euconverter(mon, rate))


          you can group them together, if this is intentional






          share|improve this answer























            up vote
            0
            down vote










            up vote
            0
            down vote









            As mentioned in comments, mon and raw are implicitly strings.
            To convert them, use e.g. mon = int(mon) or mon = float(mon).



            Be careful tho, as you should take care of invalid input (try - except TypeError block).



            Few tips:
            - Last if should use and instead of or
            - there is no difference between these two lines:



            if cur == 'Eur' or cur == 'Eur':
            print (euconverter(mon, rate))
            elif cur == 'GBP' or cur == 'Gbp':
            print (euconverter(mon, rate))


            you can group them together, if this is intentional






            share|improve this answer












            As mentioned in comments, mon and raw are implicitly strings.
            To convert them, use e.g. mon = int(mon) or mon = float(mon).



            Be careful tho, as you should take care of invalid input (try - except TypeError block).



            Few tips:
            - Last if should use and instead of or
            - there is no difference between these two lines:



            if cur == 'Eur' or cur == 'Eur':
            print (euconverter(mon, rate))
            elif cur == 'GBP' or cur == 'Gbp':
            print (euconverter(mon, rate))


            you can group them together, if this is intentional







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 9 at 9:17









            Michal Polovka

            363414




            363414
























                up vote
                0
                down vote













                Some refactored code for your text input would look like:



                legal_input = ["gbp", "eur", "yen"]
                currency = raw_input("Please enter the currency type")
                if currency.lower() in legal_input:
                #some code to do the required operations
                else:
                print('not a recognised currency type!')





                share|improve this answer





















                • We aren't taught how to use legal input therefore i cannot add it to a project :/
                  – Maple Sapling
                  Nov 9 at 9:28










                • Ok well read my comment on the question as to why your while loop stops you from catching any input errors
                  – Scott Anderson
                  Nov 9 at 10:02















                up vote
                0
                down vote













                Some refactored code for your text input would look like:



                legal_input = ["gbp", "eur", "yen"]
                currency = raw_input("Please enter the currency type")
                if currency.lower() in legal_input:
                #some code to do the required operations
                else:
                print('not a recognised currency type!')





                share|improve this answer





















                • We aren't taught how to use legal input therefore i cannot add it to a project :/
                  – Maple Sapling
                  Nov 9 at 9:28










                • Ok well read my comment on the question as to why your while loop stops you from catching any input errors
                  – Scott Anderson
                  Nov 9 at 10:02













                up vote
                0
                down vote










                up vote
                0
                down vote









                Some refactored code for your text input would look like:



                legal_input = ["gbp", "eur", "yen"]
                currency = raw_input("Please enter the currency type")
                if currency.lower() in legal_input:
                #some code to do the required operations
                else:
                print('not a recognised currency type!')





                share|improve this answer












                Some refactored code for your text input would look like:



                legal_input = ["gbp", "eur", "yen"]
                currency = raw_input("Please enter the currency type")
                if currency.lower() in legal_input:
                #some code to do the required operations
                else:
                print('not a recognised currency type!')






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 9 at 9:21









                Scott Anderson

                879




                879












                • We aren't taught how to use legal input therefore i cannot add it to a project :/
                  – Maple Sapling
                  Nov 9 at 9:28










                • Ok well read my comment on the question as to why your while loop stops you from catching any input errors
                  – Scott Anderson
                  Nov 9 at 10:02


















                • We aren't taught how to use legal input therefore i cannot add it to a project :/
                  – Maple Sapling
                  Nov 9 at 9:28










                • Ok well read my comment on the question as to why your while loop stops you from catching any input errors
                  – Scott Anderson
                  Nov 9 at 10:02
















                We aren't taught how to use legal input therefore i cannot add it to a project :/
                – Maple Sapling
                Nov 9 at 9:28




                We aren't taught how to use legal input therefore i cannot add it to a project :/
                – Maple Sapling
                Nov 9 at 9:28












                Ok well read my comment on the question as to why your while loop stops you from catching any input errors
                – Scott Anderson
                Nov 9 at 10:02




                Ok well read my comment on the question as to why your while loop stops you from catching any input errors
                – Scott Anderson
                Nov 9 at 10:02










                up vote
                0
                down vote













                It seems that what you are trying to do is to prompt the user for input and validate it, and then ask again if it is not valid.
                You can try that by wrapping each raw_input() inside a while-loop with a flag.



                To validate the currency it would be easier to cast the input to uppercase and then check agains a list of allowed possibilities.



                To validate the amount and rate, you could cast them to float inside a try-except block.



                valid_currencies = ['EUR', 'GBP']
                cur = None
                mon = None
                rate = None

                is_valid = False
                while not is_valid:
                cur = raw_input('Please give me the currency').upper()
                if cur in valid_currencies:
                is_valid = True
                else:
                print 'Not a valid currency'

                is_valid = False
                while not is_valid:
                try:
                mon = float(raw_input('Please give me the value'))
                is_valid = True
                except ValueError:
                print 'Not a valid value'

                is_valid = False
                while not is_valid:
                try:
                rate = float(raw_input('Please give me the rate'))
                is_valid = True
                except ValueError:
                print 'Not a valid rate'

                print 'Converted amount'
                print mon * rate





                share|improve this answer

























                  up vote
                  0
                  down vote













                  It seems that what you are trying to do is to prompt the user for input and validate it, and then ask again if it is not valid.
                  You can try that by wrapping each raw_input() inside a while-loop with a flag.



                  To validate the currency it would be easier to cast the input to uppercase and then check agains a list of allowed possibilities.



                  To validate the amount and rate, you could cast them to float inside a try-except block.



                  valid_currencies = ['EUR', 'GBP']
                  cur = None
                  mon = None
                  rate = None

                  is_valid = False
                  while not is_valid:
                  cur = raw_input('Please give me the currency').upper()
                  if cur in valid_currencies:
                  is_valid = True
                  else:
                  print 'Not a valid currency'

                  is_valid = False
                  while not is_valid:
                  try:
                  mon = float(raw_input('Please give me the value'))
                  is_valid = True
                  except ValueError:
                  print 'Not a valid value'

                  is_valid = False
                  while not is_valid:
                  try:
                  rate = float(raw_input('Please give me the rate'))
                  is_valid = True
                  except ValueError:
                  print 'Not a valid rate'

                  print 'Converted amount'
                  print mon * rate





                  share|improve this answer























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    It seems that what you are trying to do is to prompt the user for input and validate it, and then ask again if it is not valid.
                    You can try that by wrapping each raw_input() inside a while-loop with a flag.



                    To validate the currency it would be easier to cast the input to uppercase and then check agains a list of allowed possibilities.



                    To validate the amount and rate, you could cast them to float inside a try-except block.



                    valid_currencies = ['EUR', 'GBP']
                    cur = None
                    mon = None
                    rate = None

                    is_valid = False
                    while not is_valid:
                    cur = raw_input('Please give me the currency').upper()
                    if cur in valid_currencies:
                    is_valid = True
                    else:
                    print 'Not a valid currency'

                    is_valid = False
                    while not is_valid:
                    try:
                    mon = float(raw_input('Please give me the value'))
                    is_valid = True
                    except ValueError:
                    print 'Not a valid value'

                    is_valid = False
                    while not is_valid:
                    try:
                    rate = float(raw_input('Please give me the rate'))
                    is_valid = True
                    except ValueError:
                    print 'Not a valid rate'

                    print 'Converted amount'
                    print mon * rate





                    share|improve this answer












                    It seems that what you are trying to do is to prompt the user for input and validate it, and then ask again if it is not valid.
                    You can try that by wrapping each raw_input() inside a while-loop with a flag.



                    To validate the currency it would be easier to cast the input to uppercase and then check agains a list of allowed possibilities.



                    To validate the amount and rate, you could cast them to float inside a try-except block.



                    valid_currencies = ['EUR', 'GBP']
                    cur = None
                    mon = None
                    rate = None

                    is_valid = False
                    while not is_valid:
                    cur = raw_input('Please give me the currency').upper()
                    if cur in valid_currencies:
                    is_valid = True
                    else:
                    print 'Not a valid currency'

                    is_valid = False
                    while not is_valid:
                    try:
                    mon = float(raw_input('Please give me the value'))
                    is_valid = True
                    except ValueError:
                    print 'Not a valid value'

                    is_valid = False
                    while not is_valid:
                    try:
                    rate = float(raw_input('Please give me the rate'))
                    is_valid = True
                    except ValueError:
                    print 'Not a valid rate'

                    print 'Converted amount'
                    print mon * rate






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 9 at 9:30









                    Ralf

                    4,4164833




                    4,4164833






















                        up vote
                        0
                        down vote













                        def euconverter(mon, rate):
                        return mon * rate


                        cur = raw_input('Please give me the currency type ')
                        mon = float(raw_input('Please give me the ammount of money '))
                        rate = float(raw_input('Please give me the rate of the exchange '))
                        while True:
                        #i dont know how to make the false statement ending the program as well not necessary i think
                        if cur == 'EUR' or cur == 'Eur' or cur == 'GBP' or cur == 'Gbp':
                        if cur == 'EUR' or cur == 'Eur':
                        print (euconverter(mon, rate))
                        break
                        elif cur == 'GBP' or cur == 'Gbp':
                        print (euconverter(mon, rate))
                        break
                        # I dont know if multiple breaks should be included here
                        else:
                        print 'wrong input'
                        cur = raw_input('Please give me the currency type again correcntly this time ')
                        continue


                        With tips and help from everyone i finally got it running prompting the user to enter an other currency in the currency input line when wrong appreciate your help you'll be hearing from me soon again xD






                        share|improve this answer

























                          up vote
                          0
                          down vote













                          def euconverter(mon, rate):
                          return mon * rate


                          cur = raw_input('Please give me the currency type ')
                          mon = float(raw_input('Please give me the ammount of money '))
                          rate = float(raw_input('Please give me the rate of the exchange '))
                          while True:
                          #i dont know how to make the false statement ending the program as well not necessary i think
                          if cur == 'EUR' or cur == 'Eur' or cur == 'GBP' or cur == 'Gbp':
                          if cur == 'EUR' or cur == 'Eur':
                          print (euconverter(mon, rate))
                          break
                          elif cur == 'GBP' or cur == 'Gbp':
                          print (euconverter(mon, rate))
                          break
                          # I dont know if multiple breaks should be included here
                          else:
                          print 'wrong input'
                          cur = raw_input('Please give me the currency type again correcntly this time ')
                          continue


                          With tips and help from everyone i finally got it running prompting the user to enter an other currency in the currency input line when wrong appreciate your help you'll be hearing from me soon again xD






                          share|improve this answer























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            def euconverter(mon, rate):
                            return mon * rate


                            cur = raw_input('Please give me the currency type ')
                            mon = float(raw_input('Please give me the ammount of money '))
                            rate = float(raw_input('Please give me the rate of the exchange '))
                            while True:
                            #i dont know how to make the false statement ending the program as well not necessary i think
                            if cur == 'EUR' or cur == 'Eur' or cur == 'GBP' or cur == 'Gbp':
                            if cur == 'EUR' or cur == 'Eur':
                            print (euconverter(mon, rate))
                            break
                            elif cur == 'GBP' or cur == 'Gbp':
                            print (euconverter(mon, rate))
                            break
                            # I dont know if multiple breaks should be included here
                            else:
                            print 'wrong input'
                            cur = raw_input('Please give me the currency type again correcntly this time ')
                            continue


                            With tips and help from everyone i finally got it running prompting the user to enter an other currency in the currency input line when wrong appreciate your help you'll be hearing from me soon again xD






                            share|improve this answer












                            def euconverter(mon, rate):
                            return mon * rate


                            cur = raw_input('Please give me the currency type ')
                            mon = float(raw_input('Please give me the ammount of money '))
                            rate = float(raw_input('Please give me the rate of the exchange '))
                            while True:
                            #i dont know how to make the false statement ending the program as well not necessary i think
                            if cur == 'EUR' or cur == 'Eur' or cur == 'GBP' or cur == 'Gbp':
                            if cur == 'EUR' or cur == 'Eur':
                            print (euconverter(mon, rate))
                            break
                            elif cur == 'GBP' or cur == 'Gbp':
                            print (euconverter(mon, rate))
                            break
                            # I dont know if multiple breaks should be included here
                            else:
                            print 'wrong input'
                            cur = raw_input('Please give me the currency type again correcntly this time ')
                            continue


                            With tips and help from everyone i finally got it running prompting the user to enter an other currency in the currency input line when wrong appreciate your help you'll be hearing from me soon again xD







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 9 at 10:09









                            Maple Sapling

                            1




                            1






























                                 

                                draft saved


                                draft discarded



















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222599%2fpython-typeerror-cant-multiply-sequence-by-non-int-of-type-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

                                How to pass form data using jquery Ajax to insert data in database?

                                National Museum of Racing and Hall of Fame

                                Guess what letter conforming each word