omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Function does not give good result

    Pythonista
    not good result
    2
    3
    1585
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sendog3c
      sendog3c last edited by

      Hi forum:

      I need help to understand what is happening that the function does not give a good result.
      Thanks.

      import ui
      
      suma = 0
      suma1 = 0
      
      class Arithmetic():
      	pass
      
      a = input("Vamos a Sumar. :")
      type(suma)
      
      def math_ope(a):
      	return 2*a
      	
      	
      resultado = math_ope(a)
      print(resultado)
      a = 0
      
      
      mikael 1 Reply Last reply Reply Quote 0
      • mikael
        mikael @sendog3c last edited by

        @sendog3c, input returns a string. Convert the value with int() or float() before giving it to your function.

        1 Reply Last reply Reply Quote 0
        • sendog3c
          sendog3c last edited by

          It works. Thank you very much

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors