Python

user_input = input()
print (len(user_input))

str 클래스의 던더함수인 len()을 내장 함수인 len()을 통해 사용하였다.

len(x) → 내부적으로 → type(x).len(x) (내장 함수) (해당 클래스의 던더 메서드)

Java

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() 를 쓴다.

Javascript

// Run by Node.js
const readline = require('readline');

(async () => {
	let rl = readline.createInterface({ input: process.stdin });
	
	for await (const line of rl) {
		console.log(line.length);
	}
	
	process.exit();
})();

Node.js 진입!

(async () ⇒ { })();

이 구조를 처음 봐본다.

Unix/C에서 기반한 process.stdin을 사용한다.