I use Python 3.7.1.
I will introduce my expectations to be clearer for the reader.
I enter a choice through the input() and if I wrote a while loop, this is in order to ask me again if I enter a wrong "command"(a wrong input).
So let's see the script.py below:
champ_choix=""
while champ_choix!="1" or champ_choix!="2":
champ_choix=input("Pour cat_course tapez 1\nPour hippodrome tapez 2\n")
print("L'input est : {}".format(champ_choix))#print the input is:
print("le type de l'input est: {}".format(type(champ_choix)))#print the type is:
if champ_choix=="1":
##CHOIX DE LA COLLECTION##
collection_num=""
while collection_num!="1" or collection_num!="2":
collection_num=input("Pour la collection geny_rapp tapez 1\nPour la collection geny_cotes tapez 2\n")
#Do some instructions useless to show
if champ_choix=="2":
subprocess.run(['scrapy crawl test_shell -a nom_prix=True'],shell=True)
#if choice is "2" launch a spider with scrapy
I need to precise that I tried first without indented the if conditions above, and using other words of conditions: if champ_choix=="1": .... elif champ_choix=="2":... else: pass but it still does not work.
The issue is when I launch the script in the terminal it gives me:
(base) avy@avy-Moi:~/folder$ python script.py
Pour cat_course tapez 1
Pour hippodrome tapez 2
2 <- the input I entered
L'input est : 2
le type de l'input est: <class 'str'>
Pour cat_course tapez 1
Pour hippodrome tapez 2
As you can see, it really instantiate the right input: 2, and it is the right type of the input: str. But it makes an infinite loop, and don't understand why because considering this tutorial that's the same way.