-1

I'm new to python. I'm working on MacOS and I have python 2.7.15.

I'm trying to get input from the user :

#these two rows do not execute at the same time, it's just an example :)
annee = raw_input("Saisissez une annee : ") #works if input is string, but not if it's int
annee = input("Saisissez une annee : ") #works if input is int, but not if it's string
try:
    anne = int(annee)
    # isBissextile(annee)
except:
    print("Erreur lors de la saisie")

As said in my comments, input and raw_input are not working as expected, I want to be able to get the input either int or string, and then show exception or not

kkblue
  • 183
  • 10

1 Answers1

0

Is this how you want it? It is doing the same thing though.

try:
    annee = int(input("Saisissez une annee : "))
except:
    print("Erreur lors de la saisie")
kkblue
  • 183
  • 10