Making a timetable based on user choices, in FrenchMaking a list from user inputMaking a list from user input...

How to make my enemies feel real

Tcolorbox :: sidebyside option gives poor result

Apparently I’m calling random numbers but there's nothing in the call log

How does the income of your target audience matter for logo design?

Sing Baby Shark

Failing PhD, how to go forward?

Can I legally make a website about boycotting a certain company?

Discouraging missile alpha strikes

How can I get results over the whole domain of my non-linear differential equations?

Hollowed circle with crossed line and arrow

Workplace intimidation due to child's chronic health condition

Do error bars on probabilities have any meaning?

Which was the first story to feature space elevators?

What prevents people from lying about where they live in order to reduce state income taxes?

How to play song that contains one guitar when we have two guitarists (or more)?

How to assess the susceptibility of a U.S. company to go bankrupt?

Why is Shelob considered evil?

Ramanujan's radical and how we define an infinite nested radical

Was Opportunity's last message to Earth "My battery is low and it's getting dark"?

Movie where a woman is running away from a plant creature which rips her shorts?

Rational with finite decimals values for sine, cosine, and tangent

Uncountable set with a non-discrete metric

Making a timetable based on user choices, in French

I hate taking lectures, can I still survive in academia?



Making a timetable based on user choices, in French


Making a list from user inputMaking a list from user input - follow-upMaking user menus in a text-based gameClass-based user input validationFrench animal generatorTimetable app for myselfFrench Republican date conversionTimetable viewer - Python 3.4Text-based User Interface in PythonGenerate URLs based on user's menu choices













1












$begingroup$


i'm trying to make a French timetable in Python, but there's too many if and elif.



class Teacher:

def __init__(self, name, room):
self.room = room
self.name = nam

def __str__(self):
return '{}: {}'.format(self.name, self.room)

class Day:

def __init__(self, name, week, lessons):
self.name = name
self.week = week
self.lessons = lessons

def __str__(self):
return '{} {}n{}'.format(
self.name,
self.week,
'n'.join(' {!s}'.format(x) for x in self.lessons)


a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p = "rien", "rien","rien", "rien", "rien", "rien", "rien", "rien","rien", "rien", "rien", "rien", "rien", "rien","rien", "rien"

prog = input("Bonjour! Voulez-vous programmer une matiere dans la semaine? (o/n):").lower()

while prog == "o":

print("1-Dessin, 2-English, 3-Maths, 4-Info, 5-Electronique, 6-Biochimie:nChoisissez le chiffre de la matiere a programmer")

x = input()

print("1-Lundi, 2-Mardi, 3-Mercredi, 4-Jeudi, 5-Vendredi, 6-Samedi:nChoisissez le chiffre du jour")

y = input()

print("1- A |8H-11H|, 2- A |11H-13H| , 3- A |14H-17H| :nA quel heure?")

z = input()

if (
x == '1' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E1
elif (
a != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (
x == '1' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E1
elif (
b != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (
x == '1' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E1
elif (
c != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (
x == '1' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E1
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E1
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E1
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E1
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E1
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi!!! ")
elif (
x == '1' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E1
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E1
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E1
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E1
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E1
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E1
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E1
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E1
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '2' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E2
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E2
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E2
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E2
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E2
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E2
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E2
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E2
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '2' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E2
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E2
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E2
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E2
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E2
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E2
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E2
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E2
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '3' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E3
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E3
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E3
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E3
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E3
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E3
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E3
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E3
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '3' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E3
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E3
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E3
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E3
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E3
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E3
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E3
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E3
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '4' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E4
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E4
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E4
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E4
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E4
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E4
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E4
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E4
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '4' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E4
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E4
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E4
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E4
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E4
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E4
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E4
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E4
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi")
if (
x == '5' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E5
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E5
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E5
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E5
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E5
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E5
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E5
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E5
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '5' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E5
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E5
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E5
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E5
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E5
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E5
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E5
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E5
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '6' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E6
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E6
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E6
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E6
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E6
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E6
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E6
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E6
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '6' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E6
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E6
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E6
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E6
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E6
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E6
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E6
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E6
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
a == b and b != 'rien'
):
print("La matiere programmee Lundi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
b = 'rien'
if (
a == c and c != 'rien'
):
print("La matiere programmee Lundi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
c = 'rien'
if (
b == c and c != 'rien'
):
print("La matiere programmee Lundi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
c = 'rien'
if (
d == e and e != 'rien'
):
print("La matiere programmee Mardi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
e = 'rien'
if (
d == f and f != 'rien'
):
print("La matiere programmee Mardi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
f = 'rien'
if (
e == f and f != 'rien'
):
print("La matiere programmee Mardi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
f = 'rien'
if (
g == h and h != 'rien'
):
print("La matiere programmee Mercredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
h = 'rien'
if (
i == j and j != 'rien'
):
print("La matiere programmee Jeudi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
j = 'rien'
if (
i == k and k != 'rien'
):
print("La matiere programmee Jeudi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
k = 'rien'
if (
j == k and k != 'rien'
):
print("La matiere programmee Jeudi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
k = 'rien'
if (
l == m and m != 'rien'
):
print("La matiere programmee Vendredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
m = 'rien'
if (
l == n and n != 'rien'
):
print("La matiere programmee Vendredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
n = 'rien'
if (
m == n and n != 'rien'
):
print("La matiere programmee Vendredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
n = 'rien'
if (
o == p and p != 'rien'
):
print("La matiere programmee Samedi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
p = 'rien'









share|improve this question









New contributor




Black Atis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$












  • $begingroup$
    Welcome to CR, can you explain the logic of code in the description please?
    $endgroup$
    – 422_unprocessable_entity
    5 hours ago












  • $begingroup$
    what are a, b etc?
    $endgroup$
    – Maarten Fabré
    5 hours ago






  • 1




    $begingroup$
    Pleas edit the title of your question so it contains what this code achieves (a scheduling application?) and not what you want out of a review. Otherwise we would soon run out of variations of "How to make my code better" as question titles.
    $endgroup$
    – Graipher
    4 hours ago










  • $begingroup$
    what does a=E4 do
    $endgroup$
    – Maarten Fabré
    3 hours ago
















1












$begingroup$


i'm trying to make a French timetable in Python, but there's too many if and elif.



class Teacher:

def __init__(self, name, room):
self.room = room
self.name = nam

def __str__(self):
return '{}: {}'.format(self.name, self.room)

class Day:

def __init__(self, name, week, lessons):
self.name = name
self.week = week
self.lessons = lessons

def __str__(self):
return '{} {}n{}'.format(
self.name,
self.week,
'n'.join(' {!s}'.format(x) for x in self.lessons)


a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p = "rien", "rien","rien", "rien", "rien", "rien", "rien", "rien","rien", "rien", "rien", "rien", "rien", "rien","rien", "rien"

prog = input("Bonjour! Voulez-vous programmer une matiere dans la semaine? (o/n):").lower()

while prog == "o":

print("1-Dessin, 2-English, 3-Maths, 4-Info, 5-Electronique, 6-Biochimie:nChoisissez le chiffre de la matiere a programmer")

x = input()

print("1-Lundi, 2-Mardi, 3-Mercredi, 4-Jeudi, 5-Vendredi, 6-Samedi:nChoisissez le chiffre du jour")

y = input()

print("1- A |8H-11H|, 2- A |11H-13H| , 3- A |14H-17H| :nA quel heure?")

z = input()

if (
x == '1' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E1
elif (
a != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (
x == '1' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E1
elif (
b != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (
x == '1' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E1
elif (
c != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (
x == '1' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E1
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E1
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E1
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E1
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E1
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi!!! ")
elif (
x == '1' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E1
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E1
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E1
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E1
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E1
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E1
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E1
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E1
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '2' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E2
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E2
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E2
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E2
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E2
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E2
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E2
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E2
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '2' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E2
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E2
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E2
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E2
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E2
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E2
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E2
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E2
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '3' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E3
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E3
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E3
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E3
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E3
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E3
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E3
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E3
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '3' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E3
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E3
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E3
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E3
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E3
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E3
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E3
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E3
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '4' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E4
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E4
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E4
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E4
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E4
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E4
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E4
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E4
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '4' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E4
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E4
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E4
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E4
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E4
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E4
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E4
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E4
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi")
if (
x == '5' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E5
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E5
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E5
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E5
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E5
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E5
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E5
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E5
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '5' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E5
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E5
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E5
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E5
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E5
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E5
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E5
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E5
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '6' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E6
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E6
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E6
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E6
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E6
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E6
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E6
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E6
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '6' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E6
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E6
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E6
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E6
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E6
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E6
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E6
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E6
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
a == b and b != 'rien'
):
print("La matiere programmee Lundi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
b = 'rien'
if (
a == c and c != 'rien'
):
print("La matiere programmee Lundi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
c = 'rien'
if (
b == c and c != 'rien'
):
print("La matiere programmee Lundi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
c = 'rien'
if (
d == e and e != 'rien'
):
print("La matiere programmee Mardi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
e = 'rien'
if (
d == f and f != 'rien'
):
print("La matiere programmee Mardi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
f = 'rien'
if (
e == f and f != 'rien'
):
print("La matiere programmee Mardi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
f = 'rien'
if (
g == h and h != 'rien'
):
print("La matiere programmee Mercredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
h = 'rien'
if (
i == j and j != 'rien'
):
print("La matiere programmee Jeudi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
j = 'rien'
if (
i == k and k != 'rien'
):
print("La matiere programmee Jeudi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
k = 'rien'
if (
j == k and k != 'rien'
):
print("La matiere programmee Jeudi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
k = 'rien'
if (
l == m and m != 'rien'
):
print("La matiere programmee Vendredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
m = 'rien'
if (
l == n and n != 'rien'
):
print("La matiere programmee Vendredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
n = 'rien'
if (
m == n and n != 'rien'
):
print("La matiere programmee Vendredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
n = 'rien'
if (
o == p and p != 'rien'
):
print("La matiere programmee Samedi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
p = 'rien'









share|improve this question









New contributor




Black Atis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$












  • $begingroup$
    Welcome to CR, can you explain the logic of code in the description please?
    $endgroup$
    – 422_unprocessable_entity
    5 hours ago












  • $begingroup$
    what are a, b etc?
    $endgroup$
    – Maarten Fabré
    5 hours ago






  • 1




    $begingroup$
    Pleas edit the title of your question so it contains what this code achieves (a scheduling application?) and not what you want out of a review. Otherwise we would soon run out of variations of "How to make my code better" as question titles.
    $endgroup$
    – Graipher
    4 hours ago










  • $begingroup$
    what does a=E4 do
    $endgroup$
    – Maarten Fabré
    3 hours ago














1












1








1


1



$begingroup$


i'm trying to make a French timetable in Python, but there's too many if and elif.



class Teacher:

def __init__(self, name, room):
self.room = room
self.name = nam

def __str__(self):
return '{}: {}'.format(self.name, self.room)

class Day:

def __init__(self, name, week, lessons):
self.name = name
self.week = week
self.lessons = lessons

def __str__(self):
return '{} {}n{}'.format(
self.name,
self.week,
'n'.join(' {!s}'.format(x) for x in self.lessons)


a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p = "rien", "rien","rien", "rien", "rien", "rien", "rien", "rien","rien", "rien", "rien", "rien", "rien", "rien","rien", "rien"

prog = input("Bonjour! Voulez-vous programmer une matiere dans la semaine? (o/n):").lower()

while prog == "o":

print("1-Dessin, 2-English, 3-Maths, 4-Info, 5-Electronique, 6-Biochimie:nChoisissez le chiffre de la matiere a programmer")

x = input()

print("1-Lundi, 2-Mardi, 3-Mercredi, 4-Jeudi, 5-Vendredi, 6-Samedi:nChoisissez le chiffre du jour")

y = input()

print("1- A |8H-11H|, 2- A |11H-13H| , 3- A |14H-17H| :nA quel heure?")

z = input()

if (
x == '1' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E1
elif (
a != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (
x == '1' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E1
elif (
b != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (
x == '1' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E1
elif (
c != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (
x == '1' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E1
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E1
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E1
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E1
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E1
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi!!! ")
elif (
x == '1' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E1
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E1
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E1
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E1
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E1
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E1
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E1
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E1
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '2' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E2
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E2
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E2
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E2
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E2
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E2
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E2
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E2
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '2' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E2
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E2
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E2
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E2
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E2
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E2
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E2
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E2
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '3' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E3
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E3
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E3
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E3
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E3
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E3
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E3
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E3
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '3' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E3
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E3
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E3
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E3
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E3
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E3
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E3
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E3
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '4' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E4
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E4
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E4
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E4
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E4
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E4
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E4
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E4
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '4' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E4
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E4
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E4
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E4
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E4
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E4
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E4
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E4
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi")
if (
x == '5' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E5
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E5
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E5
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E5
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E5
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E5
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E5
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E5
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '5' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E5
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E5
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E5
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E5
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E5
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E5
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E5
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E5
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '6' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E6
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E6
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E6
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E6
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E6
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E6
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E6
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E6
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '6' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E6
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E6
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E6
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E6
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E6
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E6
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E6
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E6
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
a == b and b != 'rien'
):
print("La matiere programmee Lundi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
b = 'rien'
if (
a == c and c != 'rien'
):
print("La matiere programmee Lundi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
c = 'rien'
if (
b == c and c != 'rien'
):
print("La matiere programmee Lundi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
c = 'rien'
if (
d == e and e != 'rien'
):
print("La matiere programmee Mardi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
e = 'rien'
if (
d == f and f != 'rien'
):
print("La matiere programmee Mardi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
f = 'rien'
if (
e == f and f != 'rien'
):
print("La matiere programmee Mardi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
f = 'rien'
if (
g == h and h != 'rien'
):
print("La matiere programmee Mercredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
h = 'rien'
if (
i == j and j != 'rien'
):
print("La matiere programmee Jeudi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
j = 'rien'
if (
i == k and k != 'rien'
):
print("La matiere programmee Jeudi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
k = 'rien'
if (
j == k and k != 'rien'
):
print("La matiere programmee Jeudi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
k = 'rien'
if (
l == m and m != 'rien'
):
print("La matiere programmee Vendredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
m = 'rien'
if (
l == n and n != 'rien'
):
print("La matiere programmee Vendredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
n = 'rien'
if (
m == n and n != 'rien'
):
print("La matiere programmee Vendredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
n = 'rien'
if (
o == p and p != 'rien'
):
print("La matiere programmee Samedi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
p = 'rien'









share|improve this question









New contributor




Black Atis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




i'm trying to make a French timetable in Python, but there's too many if and elif.



class Teacher:

def __init__(self, name, room):
self.room = room
self.name = nam

def __str__(self):
return '{}: {}'.format(self.name, self.room)

class Day:

def __init__(self, name, week, lessons):
self.name = name
self.week = week
self.lessons = lessons

def __str__(self):
return '{} {}n{}'.format(
self.name,
self.week,
'n'.join(' {!s}'.format(x) for x in self.lessons)


a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p = "rien", "rien","rien", "rien", "rien", "rien", "rien", "rien","rien", "rien", "rien", "rien", "rien", "rien","rien", "rien"

prog = input("Bonjour! Voulez-vous programmer une matiere dans la semaine? (o/n):").lower()

while prog == "o":

print("1-Dessin, 2-English, 3-Maths, 4-Info, 5-Electronique, 6-Biochimie:nChoisissez le chiffre de la matiere a programmer")

x = input()

print("1-Lundi, 2-Mardi, 3-Mercredi, 4-Jeudi, 5-Vendredi, 6-Samedi:nChoisissez le chiffre du jour")

y = input()

print("1- A |8H-11H|, 2- A |11H-13H| , 3- A |14H-17H| :nA quel heure?")

z = input()

if (
x == '1' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E1
elif (
a != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (
x == '1' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E1
elif (
b != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (
x == '1' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E1
elif (
c != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (
x == '1' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E1
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E1
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E1
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E1
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E1
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi!!! ")
elif (
x == '1' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E1
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E1
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E1
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E1
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E1
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E1
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E1
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E1
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '1' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '2' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E2
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E2
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E2
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E2
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E2
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E2
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E2
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E2
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '2' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E2
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E2
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E2
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E2
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E2
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E2
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E2
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E2
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '2' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '3' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E3
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E3
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E3
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E3
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E3
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E3
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E3
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E3
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '3' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E3
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E3
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E3
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E3
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E3
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E3
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E3
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E3
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '3' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '4' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E4
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E4
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E4
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E4
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E4
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E4
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E4
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E4
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '4' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E4
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E4
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E4
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E4
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E4
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E4
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E4
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E4
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '4' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi")
if (
x == '5' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E5
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E5
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E5
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E5
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E5
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E5
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E5
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E5
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '5' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E5
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E5
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E5
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E5
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E5
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E5
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E5
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E5
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '5' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
x == '6' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E6
elif (
a != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '1' and z == '2'
):
if (
b == "rien"
):
b=E6
elif (
b != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '1' and z == '3'
):
if (
c == "rien"
):
c=E6
elif (
c != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '2' and z == '1'
):
if (
d == "rien"
):
d=E6
elif (
d != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '2' and z == '2'
):
if (
e == "rien"
):
e=E6
elif (
e != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '2' and z == '3'
):
if (
f == "rien"
):
f=E6
elif (
f != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '3' and z == '1'
):
if (
g == "rien"
):
g=E6
elif (
g != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '3' and z == '2'
):
if (
h == "rien"
):
h=E6
elif (
h != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '3' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le mercredi ")
elif (
x == '6' and y == '4' and z == '1'
):
if (
i == "rien"
):
i=E6
elif (
i != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '4' and z == '2'
):
if (
j == "rien"
):
j=E6
elif (
j != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '4' and z == '3'
):
if (
k == "rien"
):
k=E6
elif (
k != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '5' and z == '1'
):
if (
l == "rien"
):
l=E6
elif (
l != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '5' and z == '2'
):
if (
m == "rien"
):
m=E6
elif (
m != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '5' and z == '3'
):
if (
n == "rien"
):
n=E6
elif (
n != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '6' and z == '1'
):
if (
o == "rien"
):
o=E6
elif (
o != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '6' and z == '2'
):
if (
p == "rien"
):
p=E6
elif (
p != "rien"
):
print("!!!DESOLE la session est deja occupee!!! ")
elif (
x == '6' and y == '6' and z == '3'
):
print("!!!DESOLE les cours s'arretent a midi le samedi ")
if (
a == b and b != 'rien'
):
print("La matiere programmee Lundi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
b = 'rien'
if (
a == c and c != 'rien'
):
print("La matiere programmee Lundi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
c = 'rien'
if (
b == c and c != 'rien'
):
print("La matiere programmee Lundi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
c = 'rien'
if (
d == e and e != 'rien'
):
print("La matiere programmee Mardi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
e = 'rien'
if (
d == f and f != 'rien'
):
print("La matiere programmee Mardi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
f = 'rien'
if (
e == f and f != 'rien'
):
print("La matiere programmee Mardi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
f = 'rien'
if (
g == h and h != 'rien'
):
print("La matiere programmee Mercredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
h = 'rien'
if (
i == j and j != 'rien'
):
print("La matiere programmee Jeudi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
j = 'rien'
if (
i == k and k != 'rien'
):
print("La matiere programmee Jeudi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
k = 'rien'
if (
j == k and k != 'rien'
):
print("La matiere programmee Jeudi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
k = 'rien'
if (
l == m and m != 'rien'
):
print("La matiere programmee Vendredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
m = 'rien'
if (
l == n and n != 'rien'
):
print("La matiere programmee Vendredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
n = 'rien'
if (
m == n and n != 'rien'
):
print("La matiere programmee Vendredi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
n = 'rien'
if (
o == p and p != 'rien'
):
print("La matiere programmee Samedi a franchi la limite des 3h de cours, les heures supp seront retires automatiquement")
p = 'rien'






python python-3.x






share|improve this question









New contributor




Black Atis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Black Atis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 3 hours ago









200_success

129k15153416




129k15153416






New contributor




Black Atis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 5 hours ago









Black AtisBlack Atis

61




61




New contributor




Black Atis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Black Atis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Black Atis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • $begingroup$
    Welcome to CR, can you explain the logic of code in the description please?
    $endgroup$
    – 422_unprocessable_entity
    5 hours ago












  • $begingroup$
    what are a, b etc?
    $endgroup$
    – Maarten Fabré
    5 hours ago






  • 1




    $begingroup$
    Pleas edit the title of your question so it contains what this code achieves (a scheduling application?) and not what you want out of a review. Otherwise we would soon run out of variations of "How to make my code better" as question titles.
    $endgroup$
    – Graipher
    4 hours ago










  • $begingroup$
    what does a=E4 do
    $endgroup$
    – Maarten Fabré
    3 hours ago


















  • $begingroup$
    Welcome to CR, can you explain the logic of code in the description please?
    $endgroup$
    – 422_unprocessable_entity
    5 hours ago












  • $begingroup$
    what are a, b etc?
    $endgroup$
    – Maarten Fabré
    5 hours ago






  • 1




    $begingroup$
    Pleas edit the title of your question so it contains what this code achieves (a scheduling application?) and not what you want out of a review. Otherwise we would soon run out of variations of "How to make my code better" as question titles.
    $endgroup$
    – Graipher
    4 hours ago










  • $begingroup$
    what does a=E4 do
    $endgroup$
    – Maarten Fabré
    3 hours ago
















$begingroup$
Welcome to CR, can you explain the logic of code in the description please?
$endgroup$
– 422_unprocessable_entity
5 hours ago






$begingroup$
Welcome to CR, can you explain the logic of code in the description please?
$endgroup$
– 422_unprocessable_entity
5 hours ago














$begingroup$
what are a, b etc?
$endgroup$
– Maarten Fabré
5 hours ago




$begingroup$
what are a, b etc?
$endgroup$
– Maarten Fabré
5 hours ago




1




1




$begingroup$
Pleas edit the title of your question so it contains what this code achieves (a scheduling application?) and not what you want out of a review. Otherwise we would soon run out of variations of "How to make my code better" as question titles.
$endgroup$
– Graipher
4 hours ago




$begingroup$
Pleas edit the title of your question so it contains what this code achieves (a scheduling application?) and not what you want out of a review. Otherwise we would soon run out of variations of "How to make my code better" as question titles.
$endgroup$
– Graipher
4 hours ago












$begingroup$
what does a=E4 do
$endgroup$
– Maarten Fabré
3 hours ago




$begingroup$
what does a=E4 do
$endgroup$
– Maarten Fabré
3 hours ago










4 Answers
4






active

oldest

votes


















2












$begingroup$

You should think about the whole code if it is not possible to create a completely different way. I do not really know what the meaning of this code is.



But you could simplify your code:



if (
x == '1' and y == '1' and z == '1'
):
if (
a == "rien"
):
a=E1
elif (
a != "rien"
):
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
elif (...)


using this:



result = x+y+z

if result == '111' and a =='rien':
a = E1
elif result == '112' and b == 'rien':
b = E1
elif ...

else:
print("!!!!!!DESOLE la session est deja occupee!!!!!! ")





share|improve this answer








New contributor




Meph- is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$





















    1












    $begingroup$

    First thing you should consider is creating a function with the parameters x,y,z in it that return the result.



    Premièrement tu devrais créer une fonction qui a comme paramatres x,y,z et return le resultat



    like so:



    def function_name(x,y,z):
    if (
    x == '1' and y == '1' and z == '1'
    ):
    ...
    return result


    and the use dictonaries depending on the value learn more about dictonaries



    find more about dictionaries here:
    https://www.tutorialspoint.com/python/python_dictionary.htm






    share|improve this answer









    $endgroup$





















      1












      $begingroup$

      What about this:



      timetable = [[None]*3 for _ in range(6)]

      while True:
      cours = input("0-Dessin, 1-English, 2-Maths, 3-Info, 4-Electronique, 5-Biochimie:nChoisissez le chiffre de la matiere a programmern")
      if cours == '': break
      jour = input("0-Lundi, 1-Mardi, 2-Mercredi, 3-Jeudi, 4-Vendredi, 5-Samedi:nChoisissez le chiffre du journ")
      heure = input("0- A |8H-11H|, 1- A |11H-13H| , 2- A |14H-17H| :nA quel heure?")
      if timetable[jour][heure] is not None:
      timetable[jour][heure] = cours


      It creates an array you can access with timetable[jour][heure] to get the course at that particular time.






      share|improve this answer








      New contributor




      Benoît Pilatte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      $endgroup$





















        1












        $begingroup$

        Enums



        You have a definite number of courses, weekdays and timeslots. So instead of using numbers to represent them, you can better use Enums



        from enum import Enum
        class Courses(Enum):
        Dessin = 1
        English = 2
        Maths = 3
        Info = 4
        Electronique = 5
        Biochimie = 6

        class Timeslots(Enum):
        morning = "|8H-11H|"
        noon = "|11H-13H|"
        afternoon = "|14H-17H|"

        class Weekdays(Enum):
        Lundi = 1
        Mardi = 2
        Mercredi = 3
        Jeudi = 4
        Vendredi = 5
        Samedi = 6


        "rien"



        You use "rien" as a sentinel value. A better way to express this would be to use None



        input



        There is a lot of reused code to get the input, and no validation. Better would be to use a separate function to gather the input



        def get_input(inputs, message=""):
        while True:
        try:
        msg = ", ".join(f"{value.value}-{value.name}" for value in inputs)
        msg += message
        value= input(msg)
        if value.isdigit():
        return inputs(int(value))
        return inputs[value]
        except (KeyError, ValueError):
        pass


        This can be used as:



        course = get_input(Courses, """
        Choisissez le chiffre de la matiere a programmer
        """)



        if-elif



        Then at least the long if-elif-else would be clear:



        if (course = Courses.Dessin and day = Weekdays.Lundi and timeslot = Timeslots.morning):
        ...


        instead of



        if x == "1" and y == "1" and z == "1":


        dict



        Even better would be to use a datastructure to capture the schedule, instead of variables a to p. You can easily create a dict of class times:



        from itertools import product
        schedule= {
        day: {
        time: None
        for time in Timeslots
        if not (
        day in {Weekdays.Mercredi, Weekdays.Samedi}
        and time == Timeslots.afternoon
        )
        }
        for day in Weekdays
        }


        This results in:



        {<Weekdays.Lundi: 1>: {<Timeslots.morning: '|8H-11H|'>: None,
        <Timeslots.noon: '|11H-13H|'>: None,
        <Timeslots.afternoon: '|14H-17H|'>: None},
        <Weekdays.Mardi: 2>: {<Timeslots.morning: '|8H-11H|'>: None,
        <Timeslots.noon: '|11H-13H|'>: None,
        <Timeslots.afternoon: '|14H-17H|'>: None},
        <Weekdays.Mercredi: 3>: {<Timeslots.morning: '|8H-11H|'>: None,
        <Timeslots.noon: '|11H-13H|'>: None},
        <Weekdays.Jeudi: 4>: {<Timeslots.morning: '|8H-11H|'>: None,
        <Timeslots.noon: '|11H-13H|'>: None,
        <Timeslots.afternoon: '|14H-17H|'>: None},
        <Weekdays.Vendredi: 5>: {<Timeslots.morning: '|8H-11H|'>: None,
        <Timeslots.noon: '|11H-13H|'>: None,
        <Timeslots.afternoon: '|14H-17H|'>: None},
        <Weekdays.Samedi: 6>: {<Timeslots.morning: '|8H-11H|'>: None,
        <Timeslots.noon: '|11H-13H|'>: None}}


        Now to check whether a slot has been taken already, instead of the long if-elif-else, you get



        if schedule[day][timeslot] is not None:
        print("!!!!!!DESOLE la session est deja occupee!!!!!! ")


        and program a class with



        else:
        schedule[day][timeslot] = course


        Now to tackle the fact that on Saturday there is only one slot, you can precede this with:



        if time not in schedule[day]:
        print("!!!DESOLE les cours s'arretent a midi le mercredi et samedi")


        Even better would be to abstract this in a different functions, but I suggest you already try to incorporate these tips, and then see how far you get, and open a next question if you need more help.



        Some future way forwards:




        • return values instead of printing messages

        • externalize the checks whether a certain course can be taken at a certain time

        • use Exceptions to communicate failures, instead of print messages

        • To tackle the choice of not allowing the same course on one day, you can implement a small validator

        • Abstract the schedule to a Class instead of a dict






        share|improve this answer









        $endgroup$













          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "196"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Black Atis is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f213858%2fmaking-a-timetable-based-on-user-choices-in-french%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2












          $begingroup$

          You should think about the whole code if it is not possible to create a completely different way. I do not really know what the meaning of this code is.



          But you could simplify your code:



          if (
          x == '1' and y == '1' and z == '1'
          ):
          if (
          a == "rien"
          ):
          a=E1
          elif (
          a != "rien"
          ):
          print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
          elif (...)


          using this:



          result = x+y+z

          if result == '111' and a =='rien':
          a = E1
          elif result == '112' and b == 'rien':
          b = E1
          elif ...

          else:
          print("!!!!!!DESOLE la session est deja occupee!!!!!! ")





          share|improve this answer








          New contributor




          Meph- is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          $endgroup$


















            2












            $begingroup$

            You should think about the whole code if it is not possible to create a completely different way. I do not really know what the meaning of this code is.



            But you could simplify your code:



            if (
            x == '1' and y == '1' and z == '1'
            ):
            if (
            a == "rien"
            ):
            a=E1
            elif (
            a != "rien"
            ):
            print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
            elif (...)


            using this:



            result = x+y+z

            if result == '111' and a =='rien':
            a = E1
            elif result == '112' and b == 'rien':
            b = E1
            elif ...

            else:
            print("!!!!!!DESOLE la session est deja occupee!!!!!! ")





            share|improve this answer








            New contributor




            Meph- is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.






            $endgroup$
















              2












              2








              2





              $begingroup$

              You should think about the whole code if it is not possible to create a completely different way. I do not really know what the meaning of this code is.



              But you could simplify your code:



              if (
              x == '1' and y == '1' and z == '1'
              ):
              if (
              a == "rien"
              ):
              a=E1
              elif (
              a != "rien"
              ):
              print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
              elif (...)


              using this:



              result = x+y+z

              if result == '111' and a =='rien':
              a = E1
              elif result == '112' and b == 'rien':
              b = E1
              elif ...

              else:
              print("!!!!!!DESOLE la session est deja occupee!!!!!! ")





              share|improve this answer








              New contributor




              Meph- is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






              $endgroup$



              You should think about the whole code if it is not possible to create a completely different way. I do not really know what the meaning of this code is.



              But you could simplify your code:



              if (
              x == '1' and y == '1' and z == '1'
              ):
              if (
              a == "rien"
              ):
              a=E1
              elif (
              a != "rien"
              ):
              print("!!!!!!DESOLE la session est deja occupee!!!!!! ")
              elif (...)


              using this:



              result = x+y+z

              if result == '111' and a =='rien':
              a = E1
              elif result == '112' and b == 'rien':
              b = E1
              elif ...

              else:
              print("!!!!!!DESOLE la session est deja occupee!!!!!! ")






              share|improve this answer








              New contributor




              Meph- is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.









              share|improve this answer



              share|improve this answer






              New contributor




              Meph- is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.









              answered 5 hours ago









              Meph-Meph-

              1292




              1292




              New contributor




              Meph- is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.





              New contributor





              Meph- is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






              Meph- is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.

























                  1












                  $begingroup$

                  First thing you should consider is creating a function with the parameters x,y,z in it that return the result.



                  Premièrement tu devrais créer une fonction qui a comme paramatres x,y,z et return le resultat



                  like so:



                  def function_name(x,y,z):
                  if (
                  x == '1' and y == '1' and z == '1'
                  ):
                  ...
                  return result


                  and the use dictonaries depending on the value learn more about dictonaries



                  find more about dictionaries here:
                  https://www.tutorialspoint.com/python/python_dictionary.htm






                  share|improve this answer









                  $endgroup$


















                    1












                    $begingroup$

                    First thing you should consider is creating a function with the parameters x,y,z in it that return the result.



                    Premièrement tu devrais créer une fonction qui a comme paramatres x,y,z et return le resultat



                    like so:



                    def function_name(x,y,z):
                    if (
                    x == '1' and y == '1' and z == '1'
                    ):
                    ...
                    return result


                    and the use dictonaries depending on the value learn more about dictonaries



                    find more about dictionaries here:
                    https://www.tutorialspoint.com/python/python_dictionary.htm






                    share|improve this answer









                    $endgroup$
















                      1












                      1








                      1





                      $begingroup$

                      First thing you should consider is creating a function with the parameters x,y,z in it that return the result.



                      Premièrement tu devrais créer une fonction qui a comme paramatres x,y,z et return le resultat



                      like so:



                      def function_name(x,y,z):
                      if (
                      x == '1' and y == '1' and z == '1'
                      ):
                      ...
                      return result


                      and the use dictonaries depending on the value learn more about dictonaries



                      find more about dictionaries here:
                      https://www.tutorialspoint.com/python/python_dictionary.htm






                      share|improve this answer









                      $endgroup$



                      First thing you should consider is creating a function with the parameters x,y,z in it that return the result.



                      Premièrement tu devrais créer une fonction qui a comme paramatres x,y,z et return le resultat



                      like so:



                      def function_name(x,y,z):
                      if (
                      x == '1' and y == '1' and z == '1'
                      ):
                      ...
                      return result


                      and the use dictonaries depending on the value learn more about dictonaries



                      find more about dictionaries here:
                      https://www.tutorialspoint.com/python/python_dictionary.htm







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 4 hours ago









                      ThewizyThewizy

                      11710




                      11710























                          1












                          $begingroup$

                          What about this:



                          timetable = [[None]*3 for _ in range(6)]

                          while True:
                          cours = input("0-Dessin, 1-English, 2-Maths, 3-Info, 4-Electronique, 5-Biochimie:nChoisissez le chiffre de la matiere a programmern")
                          if cours == '': break
                          jour = input("0-Lundi, 1-Mardi, 2-Mercredi, 3-Jeudi, 4-Vendredi, 5-Samedi:nChoisissez le chiffre du journ")
                          heure = input("0- A |8H-11H|, 1- A |11H-13H| , 2- A |14H-17H| :nA quel heure?")
                          if timetable[jour][heure] is not None:
                          timetable[jour][heure] = cours


                          It creates an array you can access with timetable[jour][heure] to get the course at that particular time.






                          share|improve this answer








                          New contributor




                          Benoît Pilatte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






                          $endgroup$


















                            1












                            $begingroup$

                            What about this:



                            timetable = [[None]*3 for _ in range(6)]

                            while True:
                            cours = input("0-Dessin, 1-English, 2-Maths, 3-Info, 4-Electronique, 5-Biochimie:nChoisissez le chiffre de la matiere a programmern")
                            if cours == '': break
                            jour = input("0-Lundi, 1-Mardi, 2-Mercredi, 3-Jeudi, 4-Vendredi, 5-Samedi:nChoisissez le chiffre du journ")
                            heure = input("0- A |8H-11H|, 1- A |11H-13H| , 2- A |14H-17H| :nA quel heure?")
                            if timetable[jour][heure] is not None:
                            timetable[jour][heure] = cours


                            It creates an array you can access with timetable[jour][heure] to get the course at that particular time.






                            share|improve this answer








                            New contributor




                            Benoît Pilatte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






                            $endgroup$
















                              1












                              1








                              1





                              $begingroup$

                              What about this:



                              timetable = [[None]*3 for _ in range(6)]

                              while True:
                              cours = input("0-Dessin, 1-English, 2-Maths, 3-Info, 4-Electronique, 5-Biochimie:nChoisissez le chiffre de la matiere a programmern")
                              if cours == '': break
                              jour = input("0-Lundi, 1-Mardi, 2-Mercredi, 3-Jeudi, 4-Vendredi, 5-Samedi:nChoisissez le chiffre du journ")
                              heure = input("0- A |8H-11H|, 1- A |11H-13H| , 2- A |14H-17H| :nA quel heure?")
                              if timetable[jour][heure] is not None:
                              timetable[jour][heure] = cours


                              It creates an array you can access with timetable[jour][heure] to get the course at that particular time.






                              share|improve this answer








                              New contributor




                              Benoît Pilatte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.






                              $endgroup$



                              What about this:



                              timetable = [[None]*3 for _ in range(6)]

                              while True:
                              cours = input("0-Dessin, 1-English, 2-Maths, 3-Info, 4-Electronique, 5-Biochimie:nChoisissez le chiffre de la matiere a programmern")
                              if cours == '': break
                              jour = input("0-Lundi, 1-Mardi, 2-Mercredi, 3-Jeudi, 4-Vendredi, 5-Samedi:nChoisissez le chiffre du journ")
                              heure = input("0- A |8H-11H|, 1- A |11H-13H| , 2- A |14H-17H| :nA quel heure?")
                              if timetable[jour][heure] is not None:
                              timetable[jour][heure] = cours


                              It creates an array you can access with timetable[jour][heure] to get the course at that particular time.







                              share|improve this answer








                              New contributor




                              Benoît Pilatte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.









                              share|improve this answer



                              share|improve this answer






                              New contributor




                              Benoît Pilatte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.









                              answered 3 hours ago









                              Benoît PilatteBenoît Pilatte

                              2017




                              2017




                              New contributor




                              Benoît Pilatte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.





                              New contributor





                              Benoît Pilatte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.






                              Benoît Pilatte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                              Check out our Code of Conduct.























                                  1












                                  $begingroup$

                                  Enums



                                  You have a definite number of courses, weekdays and timeslots. So instead of using numbers to represent them, you can better use Enums



                                  from enum import Enum
                                  class Courses(Enum):
                                  Dessin = 1
                                  English = 2
                                  Maths = 3
                                  Info = 4
                                  Electronique = 5
                                  Biochimie = 6

                                  class Timeslots(Enum):
                                  morning = "|8H-11H|"
                                  noon = "|11H-13H|"
                                  afternoon = "|14H-17H|"

                                  class Weekdays(Enum):
                                  Lundi = 1
                                  Mardi = 2
                                  Mercredi = 3
                                  Jeudi = 4
                                  Vendredi = 5
                                  Samedi = 6


                                  "rien"



                                  You use "rien" as a sentinel value. A better way to express this would be to use None



                                  input



                                  There is a lot of reused code to get the input, and no validation. Better would be to use a separate function to gather the input



                                  def get_input(inputs, message=""):
                                  while True:
                                  try:
                                  msg = ", ".join(f"{value.value}-{value.name}" for value in inputs)
                                  msg += message
                                  value= input(msg)
                                  if value.isdigit():
                                  return inputs(int(value))
                                  return inputs[value]
                                  except (KeyError, ValueError):
                                  pass


                                  This can be used as:



                                  course = get_input(Courses, """
                                  Choisissez le chiffre de la matiere a programmer
                                  """)



                                  if-elif



                                  Then at least the long if-elif-else would be clear:



                                  if (course = Courses.Dessin and day = Weekdays.Lundi and timeslot = Timeslots.morning):
                                  ...


                                  instead of



                                  if x == "1" and y == "1" and z == "1":


                                  dict



                                  Even better would be to use a datastructure to capture the schedule, instead of variables a to p. You can easily create a dict of class times:



                                  from itertools import product
                                  schedule= {
                                  day: {
                                  time: None
                                  for time in Timeslots
                                  if not (
                                  day in {Weekdays.Mercredi, Weekdays.Samedi}
                                  and time == Timeslots.afternoon
                                  )
                                  }
                                  for day in Weekdays
                                  }


                                  This results in:



                                  {<Weekdays.Lundi: 1>: {<Timeslots.morning: '|8H-11H|'>: None,
                                  <Timeslots.noon: '|11H-13H|'>: None,
                                  <Timeslots.afternoon: '|14H-17H|'>: None},
                                  <Weekdays.Mardi: 2>: {<Timeslots.morning: '|8H-11H|'>: None,
                                  <Timeslots.noon: '|11H-13H|'>: None,
                                  <Timeslots.afternoon: '|14H-17H|'>: None},
                                  <Weekdays.Mercredi: 3>: {<Timeslots.morning: '|8H-11H|'>: None,
                                  <Timeslots.noon: '|11H-13H|'>: None},
                                  <Weekdays.Jeudi: 4>: {<Timeslots.morning: '|8H-11H|'>: None,
                                  <Timeslots.noon: '|11H-13H|'>: None,
                                  <Timeslots.afternoon: '|14H-17H|'>: None},
                                  <Weekdays.Vendredi: 5>: {<Timeslots.morning: '|8H-11H|'>: None,
                                  <Timeslots.noon: '|11H-13H|'>: None,
                                  <Timeslots.afternoon: '|14H-17H|'>: None},
                                  <Weekdays.Samedi: 6>: {<Timeslots.morning: '|8H-11H|'>: None,
                                  <Timeslots.noon: '|11H-13H|'>: None}}


                                  Now to check whether a slot has been taken already, instead of the long if-elif-else, you get



                                  if schedule[day][timeslot] is not None:
                                  print("!!!!!!DESOLE la session est deja occupee!!!!!! ")


                                  and program a class with



                                  else:
                                  schedule[day][timeslot] = course


                                  Now to tackle the fact that on Saturday there is only one slot, you can precede this with:



                                  if time not in schedule[day]:
                                  print("!!!DESOLE les cours s'arretent a midi le mercredi et samedi")


                                  Even better would be to abstract this in a different functions, but I suggest you already try to incorporate these tips, and then see how far you get, and open a next question if you need more help.



                                  Some future way forwards:




                                  • return values instead of printing messages

                                  • externalize the checks whether a certain course can be taken at a certain time

                                  • use Exceptions to communicate failures, instead of print messages

                                  • To tackle the choice of not allowing the same course on one day, you can implement a small validator

                                  • Abstract the schedule to a Class instead of a dict






                                  share|improve this answer









                                  $endgroup$


















                                    1












                                    $begingroup$

                                    Enums



                                    You have a definite number of courses, weekdays and timeslots. So instead of using numbers to represent them, you can better use Enums



                                    from enum import Enum
                                    class Courses(Enum):
                                    Dessin = 1
                                    English = 2
                                    Maths = 3
                                    Info = 4
                                    Electronique = 5
                                    Biochimie = 6

                                    class Timeslots(Enum):
                                    morning = "|8H-11H|"
                                    noon = "|11H-13H|"
                                    afternoon = "|14H-17H|"

                                    class Weekdays(Enum):
                                    Lundi = 1
                                    Mardi = 2
                                    Mercredi = 3
                                    Jeudi = 4
                                    Vendredi = 5
                                    Samedi = 6


                                    "rien"



                                    You use "rien" as a sentinel value. A better way to express this would be to use None



                                    input



                                    There is a lot of reused code to get the input, and no validation. Better would be to use a separate function to gather the input



                                    def get_input(inputs, message=""):
                                    while True:
                                    try:
                                    msg = ", ".join(f"{value.value}-{value.name}" for value in inputs)
                                    msg += message
                                    value= input(msg)
                                    if value.isdigit():
                                    return inputs(int(value))
                                    return inputs[value]
                                    except (KeyError, ValueError):
                                    pass


                                    This can be used as:



                                    course = get_input(Courses, """
                                    Choisissez le chiffre de la matiere a programmer
                                    """)



                                    if-elif



                                    Then at least the long if-elif-else would be clear:



                                    if (course = Courses.Dessin and day = Weekdays.Lundi and timeslot = Timeslots.morning):
                                    ...


                                    instead of



                                    if x == "1" and y == "1" and z == "1":


                                    dict



                                    Even better would be to use a datastructure to capture the schedule, instead of variables a to p. You can easily create a dict of class times:



                                    from itertools import product
                                    schedule= {
                                    day: {
                                    time: None
                                    for time in Timeslots
                                    if not (
                                    day in {Weekdays.Mercredi, Weekdays.Samedi}
                                    and time == Timeslots.afternoon
                                    )
                                    }
                                    for day in Weekdays
                                    }


                                    This results in:



                                    {<Weekdays.Lundi: 1>: {<Timeslots.morning: '|8H-11H|'>: None,
                                    <Timeslots.noon: '|11H-13H|'>: None,
                                    <Timeslots.afternoon: '|14H-17H|'>: None},
                                    <Weekdays.Mardi: 2>: {<Timeslots.morning: '|8H-11H|'>: None,
                                    <Timeslots.noon: '|11H-13H|'>: None,
                                    <Timeslots.afternoon: '|14H-17H|'>: None},
                                    <Weekdays.Mercredi: 3>: {<Timeslots.morning: '|8H-11H|'>: None,
                                    <Timeslots.noon: '|11H-13H|'>: None},
                                    <Weekdays.Jeudi: 4>: {<Timeslots.morning: '|8H-11H|'>: None,
                                    <Timeslots.noon: '|11H-13H|'>: None,
                                    <Timeslots.afternoon: '|14H-17H|'>: None},
                                    <Weekdays.Vendredi: 5>: {<Timeslots.morning: '|8H-11H|'>: None,
                                    <Timeslots.noon: '|11H-13H|'>: None,
                                    <Timeslots.afternoon: '|14H-17H|'>: None},
                                    <Weekdays.Samedi: 6>: {<Timeslots.morning: '|8H-11H|'>: None,
                                    <Timeslots.noon: '|11H-13H|'>: None}}


                                    Now to check whether a slot has been taken already, instead of the long if-elif-else, you get



                                    if schedule[day][timeslot] is not None:
                                    print("!!!!!!DESOLE la session est deja occupee!!!!!! ")


                                    and program a class with



                                    else:
                                    schedule[day][timeslot] = course


                                    Now to tackle the fact that on Saturday there is only one slot, you can precede this with:



                                    if time not in schedule[day]:
                                    print("!!!DESOLE les cours s'arretent a midi le mercredi et samedi")


                                    Even better would be to abstract this in a different functions, but I suggest you already try to incorporate these tips, and then see how far you get, and open a next question if you need more help.



                                    Some future way forwards:




                                    • return values instead of printing messages

                                    • externalize the checks whether a certain course can be taken at a certain time

                                    • use Exceptions to communicate failures, instead of print messages

                                    • To tackle the choice of not allowing the same course on one day, you can implement a small validator

                                    • Abstract the schedule to a Class instead of a dict






                                    share|improve this answer









                                    $endgroup$
















                                      1












                                      1








                                      1





                                      $begingroup$

                                      Enums



                                      You have a definite number of courses, weekdays and timeslots. So instead of using numbers to represent them, you can better use Enums



                                      from enum import Enum
                                      class Courses(Enum):
                                      Dessin = 1
                                      English = 2
                                      Maths = 3
                                      Info = 4
                                      Electronique = 5
                                      Biochimie = 6

                                      class Timeslots(Enum):
                                      morning = "|8H-11H|"
                                      noon = "|11H-13H|"
                                      afternoon = "|14H-17H|"

                                      class Weekdays(Enum):
                                      Lundi = 1
                                      Mardi = 2
                                      Mercredi = 3
                                      Jeudi = 4
                                      Vendredi = 5
                                      Samedi = 6


                                      "rien"



                                      You use "rien" as a sentinel value. A better way to express this would be to use None



                                      input



                                      There is a lot of reused code to get the input, and no validation. Better would be to use a separate function to gather the input



                                      def get_input(inputs, message=""):
                                      while True:
                                      try:
                                      msg = ", ".join(f"{value.value}-{value.name}" for value in inputs)
                                      msg += message
                                      value= input(msg)
                                      if value.isdigit():
                                      return inputs(int(value))
                                      return inputs[value]
                                      except (KeyError, ValueError):
                                      pass


                                      This can be used as:



                                      course = get_input(Courses, """
                                      Choisissez le chiffre de la matiere a programmer
                                      """)



                                      if-elif



                                      Then at least the long if-elif-else would be clear:



                                      if (course = Courses.Dessin and day = Weekdays.Lundi and timeslot = Timeslots.morning):
                                      ...


                                      instead of



                                      if x == "1" and y == "1" and z == "1":


                                      dict



                                      Even better would be to use a datastructure to capture the schedule, instead of variables a to p. You can easily create a dict of class times:



                                      from itertools import product
                                      schedule= {
                                      day: {
                                      time: None
                                      for time in Timeslots
                                      if not (
                                      day in {Weekdays.Mercredi, Weekdays.Samedi}
                                      and time == Timeslots.afternoon
                                      )
                                      }
                                      for day in Weekdays
                                      }


                                      This results in:



                                      {<Weekdays.Lundi: 1>: {<Timeslots.morning: '|8H-11H|'>: None,
                                      <Timeslots.noon: '|11H-13H|'>: None,
                                      <Timeslots.afternoon: '|14H-17H|'>: None},
                                      <Weekdays.Mardi: 2>: {<Timeslots.morning: '|8H-11H|'>: None,
                                      <Timeslots.noon: '|11H-13H|'>: None,
                                      <Timeslots.afternoon: '|14H-17H|'>: None},
                                      <Weekdays.Mercredi: 3>: {<Timeslots.morning: '|8H-11H|'>: None,
                                      <Timeslots.noon: '|11H-13H|'>: None},
                                      <Weekdays.Jeudi: 4>: {<Timeslots.morning: '|8H-11H|'>: None,
                                      <Timeslots.noon: '|11H-13H|'>: None,
                                      <Timeslots.afternoon: '|14H-17H|'>: None},
                                      <Weekdays.Vendredi: 5>: {<Timeslots.morning: '|8H-11H|'>: None,
                                      <Timeslots.noon: '|11H-13H|'>: None,
                                      <Timeslots.afternoon: '|14H-17H|'>: None},
                                      <Weekdays.Samedi: 6>: {<Timeslots.morning: '|8H-11H|'>: None,
                                      <Timeslots.noon: '|11H-13H|'>: None}}


                                      Now to check whether a slot has been taken already, instead of the long if-elif-else, you get



                                      if schedule[day][timeslot] is not None:
                                      print("!!!!!!DESOLE la session est deja occupee!!!!!! ")


                                      and program a class with



                                      else:
                                      schedule[day][timeslot] = course


                                      Now to tackle the fact that on Saturday there is only one slot, you can precede this with:



                                      if time not in schedule[day]:
                                      print("!!!DESOLE les cours s'arretent a midi le mercredi et samedi")


                                      Even better would be to abstract this in a different functions, but I suggest you already try to incorporate these tips, and then see how far you get, and open a next question if you need more help.



                                      Some future way forwards:




                                      • return values instead of printing messages

                                      • externalize the checks whether a certain course can be taken at a certain time

                                      • use Exceptions to communicate failures, instead of print messages

                                      • To tackle the choice of not allowing the same course on one day, you can implement a small validator

                                      • Abstract the schedule to a Class instead of a dict






                                      share|improve this answer









                                      $endgroup$



                                      Enums



                                      You have a definite number of courses, weekdays and timeslots. So instead of using numbers to represent them, you can better use Enums



                                      from enum import Enum
                                      class Courses(Enum):
                                      Dessin = 1
                                      English = 2
                                      Maths = 3
                                      Info = 4
                                      Electronique = 5
                                      Biochimie = 6

                                      class Timeslots(Enum):
                                      morning = "|8H-11H|"
                                      noon = "|11H-13H|"
                                      afternoon = "|14H-17H|"

                                      class Weekdays(Enum):
                                      Lundi = 1
                                      Mardi = 2
                                      Mercredi = 3
                                      Jeudi = 4
                                      Vendredi = 5
                                      Samedi = 6


                                      "rien"



                                      You use "rien" as a sentinel value. A better way to express this would be to use None



                                      input



                                      There is a lot of reused code to get the input, and no validation. Better would be to use a separate function to gather the input



                                      def get_input(inputs, message=""):
                                      while True:
                                      try:
                                      msg = ", ".join(f"{value.value}-{value.name}" for value in inputs)
                                      msg += message
                                      value= input(msg)
                                      if value.isdigit():
                                      return inputs(int(value))
                                      return inputs[value]
                                      except (KeyError, ValueError):
                                      pass


                                      This can be used as:



                                      course = get_input(Courses, """
                                      Choisissez le chiffre de la matiere a programmer
                                      """)



                                      if-elif



                                      Then at least the long if-elif-else would be clear:



                                      if (course = Courses.Dessin and day = Weekdays.Lundi and timeslot = Timeslots.morning):
                                      ...


                                      instead of



                                      if x == "1" and y == "1" and z == "1":


                                      dict



                                      Even better would be to use a datastructure to capture the schedule, instead of variables a to p. You can easily create a dict of class times:



                                      from itertools import product
                                      schedule= {
                                      day: {
                                      time: None
                                      for time in Timeslots
                                      if not (
                                      day in {Weekdays.Mercredi, Weekdays.Samedi}
                                      and time == Timeslots.afternoon
                                      )
                                      }
                                      for day in Weekdays
                                      }


                                      This results in:



                                      {<Weekdays.Lundi: 1>: {<Timeslots.morning: '|8H-11H|'>: None,
                                      <Timeslots.noon: '|11H-13H|'>: None,
                                      <Timeslots.afternoon: '|14H-17H|'>: None},
                                      <Weekdays.Mardi: 2>: {<Timeslots.morning: '|8H-11H|'>: None,
                                      <Timeslots.noon: '|11H-13H|'>: None,
                                      <Timeslots.afternoon: '|14H-17H|'>: None},
                                      <Weekdays.Mercredi: 3>: {<Timeslots.morning: '|8H-11H|'>: None,
                                      <Timeslots.noon: '|11H-13H|'>: None},
                                      <Weekdays.Jeudi: 4>: {<Timeslots.morning: '|8H-11H|'>: None,
                                      <Timeslots.noon: '|11H-13H|'>: None,
                                      <Timeslots.afternoon: '|14H-17H|'>: None},
                                      <Weekdays.Vendredi: 5>: {<Timeslots.morning: '|8H-11H|'>: None,
                                      <Timeslots.noon: '|11H-13H|'>: None,
                                      <Timeslots.afternoon: '|14H-17H|'>: None},
                                      <Weekdays.Samedi: 6>: {<Timeslots.morning: '|8H-11H|'>: None,
                                      <Timeslots.noon: '|11H-13H|'>: None}}


                                      Now to check whether a slot has been taken already, instead of the long if-elif-else, you get



                                      if schedule[day][timeslot] is not None:
                                      print("!!!!!!DESOLE la session est deja occupee!!!!!! ")


                                      and program a class with



                                      else:
                                      schedule[day][timeslot] = course


                                      Now to tackle the fact that on Saturday there is only one slot, you can precede this with:



                                      if time not in schedule[day]:
                                      print("!!!DESOLE les cours s'arretent a midi le mercredi et samedi")


                                      Even better would be to abstract this in a different functions, but I suggest you already try to incorporate these tips, and then see how far you get, and open a next question if you need more help.



                                      Some future way forwards:




                                      • return values instead of printing messages

                                      • externalize the checks whether a certain course can be taken at a certain time

                                      • use Exceptions to communicate failures, instead of print messages

                                      • To tackle the choice of not allowing the same course on one day, you can implement a small validator

                                      • Abstract the schedule to a Class instead of a dict







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered 3 hours ago









                                      Maarten FabréMaarten Fabré

                                      4,904417




                                      4,904417






















                                          Black Atis is a new contributor. Be nice, and check out our Code of Conduct.










                                          draft saved

                                          draft discarded


















                                          Black Atis is a new contributor. Be nice, and check out our Code of Conduct.













                                          Black Atis is a new contributor. Be nice, and check out our Code of Conduct.












                                          Black Atis is a new contributor. Be nice, and check out our Code of Conduct.
















                                          Thanks for contributing an answer to Code Review Stack Exchange!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          Use MathJax to format equations. MathJax reference.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f213858%2fmaking-a-timetable-based-on-user-choices-in-french%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Anexo:Material bélico de la Fuerza Aérea de Chile Índice Aeronaves Defensa...

                                          Always On Availability groups resolving state after failover - Remote harden of transaction...

                                          update json value to null Announcing the arrival of Valued Associate #679: Cesar Manara ...