私のループに何が間違っているのか分かりませんが、最後の行が正しくインデントされていないというエラーが表示され続けます。複数回インデントしてもエラーは発生し続けます。誰かが私のループを見ることができますか?
while itemsneeded>=1:
if (items[0]) == 86947367 :
with open("read_it.txt") as text_file:
try:
price = int(text_file.readlines()[2])
except ValueError:
print("error")
else:
new_price = int(price * (items2[0]))
print("£",new_price)
elif (items[0]) == 78364721 :
with open("read_it.txt") as text_file:
try:
price = int(text_file.readlines()[6])
except ValueError:
print("error")
else:
new_price = int(price * (items2[0]))
print("£",new_price)
elif (items[0]) == 35619833 :
with open("read_it.txt") as text_file:
try:
price = int(text_file.readlines()[10])
except ValueError:
print("error")
else:
new_price = int(price * (items2[0]))
print("£",new_price)
elif (items[0]) == 84716491 :
with open("read_it.txt") as text_file:
try:
price = int(text_file.readlines()[14])
except ValueError:
print("error")
else:
new_price = int(price * (items2[0]))
print("£",new_price)
elif (items[0]) == 46389121 :
with open("read_it.txt") as text_file:
try:
price = int(text_file.readlines()[18])
except ValueError:
print("error")
else:
new_price = int(price * (items2[0]))
print("£",new_price)
else:
continue
itemsneededが1以上でない場合、私のコードを続行します。
*最初の行を除くすべての行は正しくインデントされていません。 1つのタブ/シフトをそれらに加えます。 –
あなたは2番目の意味ですか? –
それでも、まだ間違いました。 –