+ 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

16th Apr 2020, 12:38 AM
Olia Marim
Olia Marim - avatar
10 ответов
+ 4
ChaoticDawg An alternative: if k not in [*NAME, *NAME_OF_PARTNAR]: ... else: ... Or if k not in NAME + NAME_OF_PARTNAR: ... else: ...
16th Apr 2020, 6:22 AM
Flandre Scarlet
Flandre Scarlet - avatar
+ 3
Incorrect indentation for "return" and actually, there shouldn't be any returns
16th Apr 2020, 1:00 AM
Flandre Scarlet
Flandre Scarlet - avatar
+ 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.
16th Apr 2020, 2:31 AM
ChaoticDawg
ChaoticDawg - avatar
+ 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.
16th Apr 2020, 6:32 AM
ChaoticDawg
ChaoticDawg - avatar
+ 3
27th Apr 2020, 12:16 AM
Olia Marim
Olia Marim - avatar
+ 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
16th Apr 2020, 1:34 PM
Dareen Moughrabi
Dareen Moughrabi - avatar
+ 2
Remove the return and the code should work properly..... Hope it helped
16th Apr 2020, 2:08 PM
ǟӄɛʊʟǟ
ǟӄɛʊʟǟ - avatar
+ 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.
17th Apr 2020, 4:17 PM
george
george - avatar
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()
27th Apr 2020, 12:09 AM
Safwan Faraj
Safwan Faraj - avatar
0
Olia Marim you welcome
27th Apr 2020, 12:18 AM
Safwan Faraj
Safwan Faraj - avatar