今日は簡単な質問があると思います。リストを参照する 1 から 10 までの数字を選択するようにユーザーに求めるコードがあります。ユーザーが間違った入力をした場合、つまり 55 I コードをループバックし、別の選択を行うように依頼します。これまでのところ、次のコードがありますが、ループさせる方法がわかりません。前もって感謝します
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 == 5:
print 'You have selected Roebourne as your Base Station'
elif selection == 6:
print 'You have selected Cossack as your Base Station'
elif selection == 7:
print 'You have selected Warambie as your Base Station'
elif selection == 8:
print 'You have selected Pyramid Station as your Base Station'
elif selection == 9:
print 'You have selected Eramurra Pool as your Base Station'
elif selection == 10:
print 'You have selected Sherlock as your Base Station'
else:
print 'You have made an error. Please chose a number from 1 to 10'