Py学习  »  Python

python决策逻辑与字典中的循环

Kam03 • 4 年前 • 681 次点击  

我目前正忙于为python编写代码。我必须做一个10个单词的python字典,应该提示用户搜索一个单词,程序会搜索这个单词,如果找到匹配的,显示定义。我已经得到了足够的信息,但是我还不能确定是要使用elif,还是为了什么。我需要使用循环,但我卡住了。整天都在这上面。这是我写的代码。

# 1. The user should be prompted for a word to search for.
# 2. The program will then search for the term, and if a match is found, display
# the definition.
# 2. You should demonstrate the following concepts: dictionaries, loops, decision logic, user input, and other concepts you feel are necessary.

x = {"Milwaukee": "Bucks", "Oklahoma": "Thunder" , "Portland": "Trailblazers", "Miami": "Heat" , "Boston" : "Celtics", "New York" : "Knicks" ,  "Orlando" : "Magic" , "Houston" : "Rockets" , "Chicago" : "Bulls" , "Indiana" : "Pacers"} 
team = input("enter team:")
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/40043
 
681 次点击  
文章 [ 2 ]  |  最新文章 4 年前