강의

멘토링

커뮤니티

Inflearn Community Q&A

1019jinjune's profile image
1019jinjune

asked

Dr. Nam's Python Basics, 100% Practical Use

English Word Guessing Game (Python Basics, Random Functions, Loops, Conditionals, Dictionaries)

english = words_dict[q] 부분에서

Written on

·

175

1

englsih = words_dict[q] 부분에서
if user_input.strip().lower() == english.lower():
#공백제거 strip
#소문자만들기 lower
print("정답입니다.")
break
else:
print("틀렸습니다.")
if user_input.strip().lower() != english.lower():
print("정답은 {} 입니다.".format(english))
이렇게 나오는데,
제 생각에는 그러면 english 는 해당 문제의 정답을 말하고,
user_input은 유저가 입력한 정답인거로 이해했습니다.
그러면
if user_input.strip().lower.() == english.lower():
부분에서
if user_input.strip().lower() == words_dict[q]:
로 대체해도 되지 않을까요?
왜 english 를 넣으셨는지 궁금합니다.
 
그래서 제가 english 를 words_dict[q] 로 대체하여
실행해 보았더니
잘 되는 것 같아서요.,
 
 
 
python웹-크롤링

Answer 1

0

nambaksa님의 프로필 이미지
nambaksa
Instructor

네 그렇게 하셔도 상관없습니다. ^^

1019jinjune's profile image
1019jinjune

asked

Ask a question