Python Dictionary while statement registration code

Asked 2 years ago, Updated 2 years ago, 94 views

Please help meI was looking for it for 4 hours and this is the code I came up withIt works, but I can't print out the last word added. TT: Please save meㅠ<

engkor_dict = [ ]

while True:

    eng = input('English word :')
    engkor_dict = {}

    if eng == "":            
        break

    kor = input('Korean word :')
    engkor_dict = {}

    if kor == "":
        break

print(engkor_dict)

python dictionary while-loop input

2022-09-20 10:26

1 Answers

engkor_dict=dict() # According to the homework: "declaring an empty dictionary through the sentence engkor_dict=dict()"

while True:
    eng = input('English word :')
  #  engkor_dict = {} # Must not overwrite already declared engkor_dict

    if eng == "":            
        break

    kor = input('Korean word :')
    #engkor_dict = {} # Must not overwrite already declared engkor_dict

    if kor == "":
        break
    Engkor_dict[eng] = kor # According to the homework: "Registration of English words and Korean words entered is made through engkor_dict[eng] = kor sentences."

print(engkor_dict)


2022-09-20 10:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.