我创建了一个编号为1-10的名字列表.我希望用户能够输入数字(1-10)来选择名称.我有以下代码,但仍然无法让它工作.我是python的新手.谢谢您的帮助
def taskFour():
1 == Karratha_Aero
2 == Dampier_Salt
3 == Karratha_Station
4 == Roebourne_Aero
5 == Roebourne
6 == Cossack
7 == Warambie
8 == Pyramid_Station
9 == Eramurra_Pool
10 == Sherlock
print''
print 'Choose a Base Weather Station'
print 'Enter the corresponding station number'
selection = int(raw_input('Enter a number from: 1 to 10'))
if selection == 1:
selectionOne()
elif selection == 2:
selectionTwo()
elif selection == 3:
selectionThree()
Run Code Online (Sandbox Code Playgroud) 今天我想我可能有一个简单的问题.我有一些代码要求用户选择1到10之间的数字,这是指列表.如果用户输入的输入不正确,即55我要循环的代码是什么,并要求他们做出另一个选择.到目前为止,我有以下代码,但我不确定如何使其循环.提前致谢
print 'Choose a Base Weather Station'
print 'Enter the corresponding station number'
selection = int(raw_input('Enter a number from: 1 to 10'))
if selection == 1:
print 'You have selected Karratha Aero as your Base Station'
elif selection == 2:
print 'You have selected Dampier Salt as your Base Station'
elif selection == 3:
print 'You have selected Karratha Station as your Base Station'
elif selection == 4:
print 'You have selected Roebourne Aero as your Base Station'
elif selection …Run Code Online (Sandbox Code Playgroud)