Bonjour, j'ai ouvert ma première discussion car je suis actuellement en train d'apprendre le python et j'essaie les choses que j'ai appris mais je n'arrive pas à mes fins. Alors voilà, j'aimerai appeler une fonction à partir d'un try / except mais je n'y arrive pas donc j'implore votre aide afin que vous m'éclairiez.
Voila mon script:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
 
from math import *
from random import *
def addition():
    nmb_1 = input("Choisis un chiffre ")
    nmb_2 = input("Choisis-en un autre ")
    nmb_1 = int(nmb_1)
    nmb_2 = int(nmb_2)
    print(nmb_1 + nmb_2)
 
def soustraction():
    nmb_1 = input("Choisis un chiffre ")
    nmb_2 = input("Choisis-en un autre ")
    nmb_1 = int(nmb_1)
    nmb_2 = int(nmb_2)
    print(nmb_1 - nmb_2)
 
def multiplication():
    nmb_1 = input("Choisis un chiffre ")
    nmb_2 = input("Choisis-en un autre ")
    nmb_1 = int(nmb_1)
    nmb_2 = int(nmb_2)
    print(nmb_1 * nmb_2)
 
def division():
    nmb_1 = input("Choisis un chiffre ")
    nmb_2 = input("Choisis-en un autre ")
    nmb_1 = int(nmb_1)
    nmb_2 = int(nmb_2)
    print(nmb_1 / nmb_2)
 
def random():
    nmb_1 = input("Choisis le nombre minimal ")
    nmb_2 = input("Choisis le nombre maximal ")
    nmb_1 = int(nmb_1)
    nmb_2 = int(nmb_2)
    print(randint(nmb_1, nmb_2))
 
print("Choisissez un mode opératoire")
choice = input()
 
try:
    if choice is "addition":
        addition()
 
    if choice is "soustraction":
        soustraction()
 
    if choice is "multiplication":
        multiplication()
 
    if choice is "division":
        division()
 
except:
    print("erreur")
Merci d'avoir pris de votre temps pour lire.
Cordialement,
xxloubexx