2016-12-14 11 views
-2

私はpythonのプログラムを書いていました。私がそれを書いたときには、IndentationErrorがあると言われましたが、それは分かっていますが、なぜ分かりません。すべてが合法だと思われます:/インデントエラーですが、理由を理解できません。

# encoding : utf-8 

from math import * 
def menu(): 
    print(""" 
    Choisissez parmi ces actions : 

    [1] Afficher un vecteur donné par deux points 
    [2] Afficher le résultat de l'addition ou de la soustraction de deux vecteurs 
    [3] Afficher le résultat de la multiplication d'un vecteur par un nombre 
    [4] Afficher le produit scalaire de deux vecteurs de R2 ou de R3 
    [5] Afficher le produit vectoriel de deux vecteurs de R3 
    [6] Afficher la norme d'un vecteur 
    [7] Afficher la normalisation d'un vecteur 
    [8] Afficher le projeté orthogonal d'un vecteur sur un autre 
    [9] Afficher l'angle (compris entre 0° et 180°) entre deux vecteurs 
    [10] Afficher si un vecteur est unitaire ou non 
    [11] Afficher si deux vecteurs sont colinéaires ou non 
    [12] Afficher si deux vecteurs sont orthogonaux ou non 

    [0] Quitter le programme 
    """) 

    choice =input() 
    if choice == "1": 
     print("Entrez votre vecteur sous la forme d'une liste : ") 
     vector = eval(input("Vecteur")) 
     print(vector) 
    elif choice == "2": 

    elif choice == "3": 
#it says that the line just above contains an error 
    elif choice == "4": 

    elif choice == "5": 

    elif choice == "6": 

    elif choice == "7": 

    elif choice == "8": 

    elif choice == "9": 

    elif choice == "10": 

    elif choice == "11": 

    elif choice == "12": 

    elif choice == "0": 
     return None 

フランス語の部分について気にしないでください、それは重要ではありません。重要な部分はelifの機能です。

PS:私は6ヶ月以来のpythonを使用するので、私は私がやっているか知っているが、私はプロ

おかげではないよ:D

+1

これらの 'elif' ** _ statements _ **の中に入れる予定は何ですか? –

+3

'elif'ブロックには何らかの内容が必要です。開発中に何もしない場合は、少なくとも 'pass'を追加してください。 – Matthias

+0

「パス」とは何ですか? @Matthias – Blaxou

答えて

1

あなたが何か書くことはできません:あなたはそれ以降の実装にしたいので、もし、これがIndentationError例外を発生させ

elif choice == "2": 

elif choice == "3": 

elif choice == "2": 
    pass 

elif choice == "3": 
    pass 

よりより次のようにpass statementを使用できます。ドキュメント:

passステートメントは何もしません。ステートメントが構文的に必要な である場合に使用できますが、プログラムはアクションを必要としません。

1

あなたは下に何かを残すことはできません「:」空白。

あなたが書いた後、何かをしたくない場合は、次の

elif choice == "2": 
    pass 
関連する問題