user_input = input()
print (len(user_input))
str 클래스의 던더함수인 len()을 내장 함수인 len()을 통해 사용하였다.
len(x) → 내부적으로 → type(x).len(x) (내장 함수) (해당 클래스의 던더 메서드)
import java.io.*;
class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(br.readLine().length());
}
}
.readLine()이 throws IOException을 요구하기에 throws Exception을 두는 게 좋다.
전에 배운대로, int[], String[] 등에는 .length, String에는 .length() 를 쓴다.