#2
dictionary = {"멋사": "멋쟁이 사자처럼", "파이썬": "지금 배우는 언어"}
def create_word():
#dictionary[input("Enter word: ")] =input("Enter meaning: ")으로 하면 순서가 바뀌어서 출력되는데 이유가 뭘까요 ..?
k=input("Enter word: ")
t=input("Enter meaning: ")
dictionary[k]=t
print("The word has been successfully registered\n")
def read_dictionary():
print("Dictionary")
print("---")
for key, value in dictionary.items():
print(key, ':', value)
def update_word():
#dictionary[input("Enter word: ")] =input("Enter meaning: ")
a=input("Enter word: ")
b=input("Enter meaning: ")
dictionary[a]=b
print("The word has been successfully updated")
def delete_word():
z=input("Enter word: ")
del dictionary[z]
print("The word has been successfully deleted")
def console_help():
print("Command list")
print("---")
print("C for create")
print("R for read")
print("U for update")
print("D for delete")
print("Q for quit")
def receive_input():
command = input("Input command: ")
if command == 'c' or command == 'C':
create_word()
return True
if command == 'r' or command == 'R':
read_dictionary()
return True
if command == 'u' or command == 'U':
update_word()
return True
if command == 'd' or command == 'D':
delete_word()
return True
if command == 'q' or command == 'Q':
return False
else:
print("Please enter one of the letters above.")
return True
def main():
console_help()
while receive_input():
pass
if __name__ == "__main__":
main()
top of page
실제 작동 상태를 확인하려면 라이브 사이트로 이동하세요.
수정: 2021년 5월 02일
210502
210502
댓글 0개
좋아요
댓글(0)
bottom of page