For context, I am trying to translate two languages (In the case English to “Pirate”). I am given a dictionary of about 16 key/value pairs and have to separate them, then stick ’em back together as a string value. I have most of it somewhat worked out the way my teacher told me to do it (He’s a psychology teacher with a minor in some form of programming I believe) any help on getting it to spit out the translated values would be very much appreciated.
def ep(): ep = {yes: 'aye', no: 'nay', hello: 'ahoy', stop: 'avast', i: 'me', my: 'me', you: 'ye', the: 'th’', friend: 'matey', money: 'doubloons', treasure: 'booty', strong: 'heave - ho', take: 'pillage', there: 'thar', lady: 'lass', to: 't', your: 'yerr'} phrase = input() phrase = phrase.split list() #checks if the word being entered is in the dictionary # if so it will return the value attached to said word, if not it will simply be put into the list as is for word in ep.keys(): if word in ep.keys: list.append(ep.keys[word]) elif word not in ep.keys(): list.append() output =
The thing confusing me is essentially everything below and including “if word in ep.keys():” and the “list()” in the center. supposedly that needs to be there however I am so lost as to what I need to do to fix this up and finish it.
submitted by /u/Chao1c_Crout0ns
[link] [comments]
r/learnpython For context, I am trying to translate two languages (In the case English to “Pirate”). I am given a dictionary of about 16 key/value pairs and have to separate them, then stick ’em back together as a string value. I have most of it somewhat worked out the way my teacher told me to do it (He’s a psychology teacher with a minor in some form of programming I believe) any help on getting it to spit out the translated values would be very much appreciated. def ep(): ep = {yes: ‘aye’, no: ‘nay’, hello: ‘ahoy’, stop: ‘avast’, i: ‘me’, my: ‘me’, you: ‘ye’, the: ‘th’’, friend: ‘matey’, money: ‘doubloons’, treasure: ‘booty’, strong: ‘heave – ho’, take: ‘pillage’, there: ‘thar’, lady: ‘lass’, to: ‘t’, your: ‘yerr’} phrase = input() phrase = phrase.split list() #checks if the word being entered is in the dictionary # if so it will return the value attached to said word, if not it will simply be put into the list as is for word in ep.keys(): if word in ep.keys: list.append(ep.keys[word]) elif word not in ep.keys(): list.append() output = The thing confusing me is essentially everything below and including “if word in ep.keys():” and the “list()” in the center. supposedly that needs to be there however I am so lost as to what I need to do to fix this up and finish it. submitted by /u/Chao1c_Crout0ns [link] [comments]
For context, I am trying to translate two languages (In the case English to “Pirate”). I am given a dictionary of about 16 key/value pairs and have to separate them, then stick ’em back together as a string value. I have most of it somewhat worked out the way my teacher told me to do it (He’s a psychology teacher with a minor in some form of programming I believe) any help on getting it to spit out the translated values would be very much appreciated.
def ep(): ep = {yes: 'aye', no: 'nay', hello: 'ahoy', stop: 'avast', i: 'me', my: 'me', you: 'ye', the: 'th’', friend: 'matey', money: 'doubloons', treasure: 'booty', strong: 'heave - ho', take: 'pillage', there: 'thar', lady: 'lass', to: 't', your: 'yerr'} phrase = input() phrase = phrase.split list() #checks if the word being entered is in the dictionary # if so it will return the value attached to said word, if not it will simply be put into the list as is for word in ep.keys(): if word in ep.keys: list.append(ep.keys[word]) elif word not in ep.keys(): list.append() output =
The thing confusing me is essentially everything below and including “if word in ep.keys():” and the “list()” in the center. supposedly that needs to be there however I am so lost as to what I need to do to fix this up and finish it.
submitted by /u/Chao1c_Crout0ns
[link] [comments]