Indentation Error but don't understand why?

128 Views Asked by At

I wrote a python programm and when I lauch it, it says that there is a IndentationError, I know what is it but don't understand why. Everything seems legit to me :/

# 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

Don't mind about the french part, it's not important. The important part is with the elif functions.

PS: I use python since 6 months so I know what I'm doing but I'm not a pro

Thanks :D

2

There are 2 best solutions below

0
On BEST ANSWER

You cannot leave something below a ':' blank.

If you don't want to do anything then write:

elif choice == "2":
   pass
0
On

You can not write something like:

elif choice == "2":

elif choice == "3":

This raises IndentationError exception, so if you want to implement that later you can use pass statement like below:

elif choice == "2":
    pass

elif choice == "3":
    pass

From pass documentation:

The pass statement does nothing. It can be used when a statement is required syntactically but the program requires no action.