Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 036074e

Browse files
Create Exercise on Dictionary - Level 1.py
1 parent 34c0925 commit 036074e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Problem Statement
2+
# Represent a small bilingual (English-Swedish) glossary given below as a Python dictionary
3+
#
4+
# {"merry":"god", "christmas":"jul", "and":"och", "happy":"gott", "new":"nytt", "year":"ar"}
5+
#
6+
# and use it to translate your Christmas wishes from English into Swedish.
7+
#
8+
# That is, write a python function translate() that accepts the bilingual dictionary and a list of English words (your Christmas wish)
9+
# and returns a list of equivalent Swedish words.
10+
11+
#lex_auth_012693774187716608134
12+
13+
def translate(bilingual_dict,english_words_list):
14+
#Write your logic here
15+
swedish_words_list = list()
16+
for i in english_words_list:
17+
swedish_words_list.append(bilingual_dict[i])
18+
19+
return swedish_words_list
20+
21+
22+
bilingual_dict= {"merry":"god", "christmas":"jul", "and":"och", "happy":"gott", "new":"nytt", "year":"ar"}
23+
english_words_list=["merry","christmas"]
24+
print("The bilingual dict is:",bilingual_dict)
25+
print("The english words are:",english_words_list)
26+
27+
swedish_words_list=translate(bilingual_dict, english_words_list)
28+
print("The equivalent swedish words are:",swedish_words_list)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /