len(s)

Pythonには文字列(またはコースの後半で紹介する他のコンテナ)の長さを取得するための組み込み関数があります。len()を使用して文字列の長さを取得することができます。

a = 'some random string'
print(len(a))

このプログラムは18を出力します。

チャレンジ

2つの文字列が与えられたとき、短い方を1行目に、長い方を2行目に出力してください。

入力

出力

short one
a very long text here

short one
a very long text here

AAABBB
AB

AB
AAABBB

BB
AA

BB
AA

Constraints

Time limit: 3 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue