Pythonのエラーの理由がわからない

実現したいこと

こんにちは。最近Pythonを勉強している初心者です。Pythonで以下のコードを編集したらエラーが出てしまい、原因などを色々調べましたが全然解決ができません。
自分と同じまたは似たような現象が起きて解決した方、Pythonに詳しい方、以下の結果を得たいです。
すみませんが、よろしくお願いします。
部屋番号を入力して下さい: 3
→ 寅 年

発生している問題・分からないこと

配列の数を減らしただけで、エラーが出ました。

エラーメッセージ

error

1--------------------------------------------------------------------------- 2IndexError Traceback (most recent call last) 3Cell In[9], line 5 4 3 number_of_eto = (room_number + 8) % 12 5 4 eto_tuple = ('子', '丑', '虎', '丑', '子', '丑', '子', '丑', '子', '丑') 6----> 5 eto_name = eto_tuple[number_of_eto] 7 6 print('あなたの部屋番号は', eto_name, 'です') 8 9IndexError: tuple index out of range

該当のソースコード

Python

1room_str = input('あなたの部屋番号を入力して下さい:')2room_number = int(room_str)3number_of_eto = (room_number + 8) % 124eto_tuple = ('子', '丑', '虎', '丑', '辰', '巳', '午', '未', '申', '酉', '戌', '亥')5eto_name = eto_tuple[number_of_eto]6print('あなたの部屋番号は', eto_name, 'です')7

Python

1room_str = input('あなたの部屋番号を入力して下さい:')2room_number = int(room_str)3number_of_eto = (room_number + 8) % 124eto_tuple = ('子', '丑', '虎', '丑', '子', '丑', '子', '丑', '子', '丑')5eto_name = eto_tuple[number_of_eto]6print('あなたの部屋番号は', eto_name, 'です')7

試したこと・調べたこと

上記の詳細・結果

eto_tuple = ('子', '丑', '虎', '丑', '辰', '巳', '午', '未', '申', '酉', '戌', '亥')をeto_tuple = ('子', '丑', '虎', '丑', '子', '丑', '子', '丑', '子', '丑')に変更をしたら、このようなエラーが発生しました。

補足

特になし

コメントを投稿

0 コメント