728x90

👉 기본 환경

- Language: Python

- IDE: Replit

 

 

⌨️ 코드

1
2
print(int(weight)/int(height)**2);
 
 
 

 

 

🖨️오류

ValueError: invalid literal for int() with base 10: '1.8'

 

 

📡 원인

int 타입의 값에 1.8 입력

 

 

📰 해결 방법

1
2
print(float(weight)/float(height)**2);
 
 
 

변수 weight, height 값이 변환 시, 실수일 경우 int()가 아닌 float()으로 형 변환

 

728x90