Error executing "module" code

Asked

Viewed 75 times

0

When performing an exercise on module, the following "Typeerror: not all Arguments converted During string formatting,"happens?

#coding: utf-8
num = input("Digite um número: ")
if(num % 2 ==0):
    print("o número é par")
else: 
    print("o número é impar")
  • 2

    "following error"? I did not find the error in the question.

  • Typeerror: not all Arguments converted During string formatting

1 answer

1


The return of input is string. To fix, you must convert using int()

Thus:

num = int(input("Digite um número: "))
  • Understood!! So the tutorial is wrong? http://excript.com/python/modulo-da-divisao-python.html

  • 1

    I looked now and yes: the code is wrong.

  • If that answer helped you, mark it as correct.

  • 1

    @Raulnascimento Even on this page has a comment from 2017 pointing out the error (and a response from the moderator of the site acknowledging that it is wrong), but to date have not corrected...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.