#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목int(input())와 input() 차이에 대해서2022-04-18 23:46
작성자

import random

intRandom = random.randrange(0, 10)  

    

while True:

    userInput = int(input("Enter an integer: "))   (a)


    if (userInput > intRandom):

        print("Big")

    elif userInput == intRandom:

        print("Same")

    else:

         print("Small")

                     

    if (userInput != intRandom):

        continue

    else:

        break




진한 글씨로 쓴 줄에서 int(input()) 형태로 쓰면 잘 작동하지만 그냥 input()

(b) userInput = input("Enter an integer: ") 을 사용하면 오류가 나는데요.. 


제가 (b) input에서 정수를 넣어주면 그대로 정수로 인식해서 오류가 없어야되는것 아닌가요?


왜 (a)처럼 해야지만 오류없이 프로그램이 작동하는건가요?


댓글