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?

問題概要

3つの小文字からなる文字列が与えられるので、その先頭の文字を大文字にして繋げて出力する

解法と実装

1. upperメソッド

Pythonではupperメソッドを使うことで、簡単に小文字を大文字にして出力することができます。
同様にlowerメソッドを用いると、大文字を小文字にすることもできます。
文字列を足して出力することで、シンプルに書くことができます。

a, b, c = input().split() # 入力を受け取る
print(a[0].upper() + b[0].upper() + c[0].upper()) # それぞれの文字列の最初の文字([0])を大文字にして(upper())出力

2. 文字コード

アルファベットは連続した文字コードなので、文字コードを利用することでも書くことができます。
大文字と小文字の間に記号が入っているため、26ではなく32になることに注意してください。

a, b, c = input().split()
print(chr(ord(a[0]) - 32) + chr(ord(b[0]) - 32) + chr(ord(c[0]) - 32))
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?