+ 3
Hi why my code is not working I Am new programme ?? ?? ? 😢
s = " " NAME = ["walid", "salim", " zohir", "leila", " hanane", "najat", " fadila"] NAME_OF_PARTNAR = ["sara", "yasmin", " sahar", "tahar", " Yasin", "mostafa", " halim"] KIDS_N = [0, 2, 3] k = input('entrée votre nom : ') if k not in NAME or NAME_OF_PARTNAR : print(k + s + "!") print( "Vous n'êtes pas de la famille") print(" ¯\_(ツ)_/¯ ") return elif k in NAME or NAME_OF_PARTNAR : print( k + "Bienvenue, vous êtes de la") print(" familleᕦ( ͡͡~͜ʖ ͡° )ᕤ") https://code.sololearn.com/c17vfjDgLDC9/?ref=app
10 Respostas
+ 4
ChaoticDawg An alternative:
if k not in [*NAME, *NAME_OF_PARTNAR]: ...
else: ...
Or
if k not in NAME + NAME_OF_PARTNAR: ...
else: ...
+ 3
Incorrect indentation for "return"
and actually, there shouldn't be any returns
+ 3
Remove return and fix your if-elif conditions.
if k not in NAME or NAME_OF_PARTNAR:
is not valid and will always be truthy.
Use;
if k not in NAME and k not in NAME_OF_PARTNAR :
You'll need to do the same for the elif, but keep or.
+ 3
Flandre Scarlet Yes, but given the OP's level I didn't think that I would confuse them with unpacking. So, if they ask I'll let you explain it. Lol
But, I guess appending to 2 together is pretty straight forward.
+ 3
Safwan Faraj thanx
+ 2
https://code.sololearn.com/cNvbTwWr87vd/?ref=app
there is no need for return it is used in def not in if statement good luck
+ 2
Remove the return and the code should work properly.....
Hope it helped
+ 1
Im case of return, you need indent, otherwise elif statement not correct.
If you indent the return command like print(k+s.... In this case it will be ok.but in this case return not need so this command can be removed since you use if elif
You need return statemt only if you use if statement instead of elif.
Also you can leave return command with correct ident, remove elif command line,correct ident of next 2 lines. It will also work.
0
#!/usr/bin/python3
# -*- coding: utf-8 -*-
def main():
s = None
NAME = ["walid", "salim", " zohir", "leila", " hanane", "najat", " fadila"]
NAME_OF_PARTNAR = ["sara", "yasmin", " sahar", "tahar", " Yasin", "mostafa", " halim"]
KIDS_N = [0, 2, 3]
def search():
k = input('entrée votre nom :')
if k in NAME:
out = (NAME_OF_PARTNAR[NAME.index(k)])
print("%s Bienvenue, vous êtes de la"% out)
print("familleᕦ( ͡͡~͜ʖ ͡° )ᕤ")
search()
else:
print("Bienvenue, vous êtes de la")
print("familleᕦ( ͡͡~͜ʖ ͡° )ᕤ")
search()
search()
if __name__ == "__main__":
main()
0
Olia Marim you welcome