実現したいこと
isdigitを使い、1以上の数字を入力した場合は、その数字から1になるまで「Line 番号」となるようなコードを作成したいのですがうまくいきません。
前提
isdigitを使い、1以上の数字を入力した場合は、その数字から1になるまで「Line 番号」となるようなコードを作成したいのですがうまくいきません。
発生している問題・エラーメッセージ
File "C:/Users/eisuk/OneDrive/BCDE101_Programming/4-1-1Q2.py", line 5, in <module>
if display_number.isdigit():
AttributeError: 'builtin_function_or_method' object has no attribute 'isdigit'
該当のソースコード
Python
1display_number = input('Please enter the number of lines you would like displayed: ').strip 2start = str(display_number) 3stop = 0 4step = -1 5if display_number.isdigit(): 6 for number in range(start, stop, step): 7 print('Line',number) 8 print('Loop finished.') 9elif display_number == '0': 10 print('No loop requested.') 11else: 12 print(f'Integers only please.') 13print('Bye.')
試したこと
isdigitの入力
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。

回答2件
あなたの回答
tips
プレビュー