これは解法が2つある
ひとつはそれぞれの言語で大文字判定メソッドがあればそれが使える
pythonの場合はisupper()
(小文字はislower()
)
if str(input()).isupper() == True:
print('YES')
else:
print('NO')
(2024.01.04修正)
上記のような==TRUEというような書き方はPythonの書き方ではだめだそうです。
私もオリジナルのガイドを読んで初めて知りました。。。
なので修正しておきます。
if str(input()).isupper():
print('YES')
else:
print('NO')
もう1つはUnicordの番号を調べる方法
これはord()
を使う
つまり、大文字の”A"と”Z"の間になければOKってことですね
UnicordはVBA屋時代のときにもお世話になってましたね
c = input()
if ord(c) >= ord("A") and ord(c) <= ord("Z"):
print("YES")
else:
print("NO")
(2024.01.04修正)
コメントを頂いたのですが、コメントのご提案が私のよりもっと直感的なので、こちらも
書き直しておきます
c = input()
if ord("A") <= ord(c) <= ord("Z"):
print("YES")
else:
print("NO")