0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

文字列(N個)を表示させる

0
Last updated at Posted at 2019-09-17

input関数を使って、文字列をN個表示させてみる

python3で、input関数を使用し、入力した数字分だけ文字列"ABC"を出力したいと思います。

コード例

x = input()
y = int(x)
print("ABC" * y)

コードの解釈

x = input()
変数xに、input関数により入力された文字を代入

y = int(x)
input関数で得られた文字は、str型なので、int型に変換し、変数yに代入

print("ABC" * y)
文字列"ABC"を、input関数により入力された数だけ表示させる

最後に

pythonを触り始めたばかりなので、記載内容に間違いがある場合は、ご指摘ください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?