CODE IN PYTHON # Take input for word pairs wordPairsInputsThroughConsole = input() # split pairs into list eachWordList
Posted: Thu Jul 14, 2022 2:07 pm
CODE IN PYTHON
# Take input for word pairswordPairsInputsThroughConsole = input()
# split pairs into listeachWordList = wordPairsInputsThroughConsole.split()# Take input for namenameToSearchInWrdPairs = input()
# Convert eachWordList list to dictionary of alternate items byusing slicing and zip methoddictionaryOfWordPairs = (dict(zip(eachWordList[::2],eachWordList[1::2])))
# print the matched word if foundif nameToSearchInWrdPairs in dictionaryOfWordPairs: print(dictionaryOfWordPairs[nameToSearchInWrdPairs])else: # otherwise print a message of not found print("Not found")
THIS IS WHAT I HAVE SO FAR BUT I KEEP GETTING WRONGOUTPUTS.
1: Compare outputkeyboard_arrow_up
0 / 3
Output differs. See highlights below. Special characterlegend
Input
Joe,123-5432 Linda,983-4123 Frank,867-5309 Frank
Your output
Not found
Expected output
867-5309
2: Compare outputkeyboard_arrow_up
0 / 3
Output differs. See highlights below. Special characterlegend
Input
Jasmin,312-3145 Scooby-Doo,093-1212 Jasmin
Your output
Not found
Expected output
312-3145
3: Compare outputkeyboard_arrow_up
0 / 2
Output differs. See highlights below. Special characterlegend
Input
Mo,391-0993 Rachel,019-1265 Ruby,010-8712 Steve,312-3318Maria,871-0091 Rachel
Your output
Not found
Expected output
019-1265
4: Compare outputkeyboard_arrow_up
0 / 2
Output differs. See highlights below. Special characterlegend
Input
Sally,190-1214 Sue,119-6442 Sue
Your output
Not found
Expected output
119-6442
# Take input for word pairswordPairsInputsThroughConsole = input()
# split pairs into listeachWordList = wordPairsInputsThroughConsole.split()# Take input for namenameToSearchInWrdPairs = input()
# Convert eachWordList list to dictionary of alternate items byusing slicing and zip methoddictionaryOfWordPairs = (dict(zip(eachWordList[::2],eachWordList[1::2])))
# print the matched word if foundif nameToSearchInWrdPairs in dictionaryOfWordPairs: print(dictionaryOfWordPairs[nameToSearchInWrdPairs])else: # otherwise print a message of not found print("Not found")
THIS IS WHAT I HAVE SO FAR BUT I KEEP GETTING WRONGOUTPUTS.
1: Compare outputkeyboard_arrow_up
0 / 3
Output differs. See highlights below. Special characterlegend
Input
Joe,123-5432 Linda,983-4123 Frank,867-5309 Frank
Your output
Not found
Expected output
867-5309
2: Compare outputkeyboard_arrow_up
0 / 3
Output differs. See highlights below. Special characterlegend
Input
Jasmin,312-3145 Scooby-Doo,093-1212 Jasmin
Your output
Not found
Expected output
312-3145
3: Compare outputkeyboard_arrow_up
0 / 2
Output differs. See highlights below. Special characterlegend
Input
Mo,391-0993 Rachel,019-1265 Ruby,010-8712 Steve,312-3318Maria,871-0091 Rachel
Your output
Not found
Expected output
019-1265
4: Compare outputkeyboard_arrow_up
0 / 2
Output differs. See highlights below. Special characterlegend
Input
Sally,190-1214 Sue,119-6442 Sue
Your output
Not found
Expected output
119-6442