사용자가 입력 한 숫자의 값을 두 배로 표시하고 싶습니다.float 또는 int로 입력
spam = int(input('choose any number: '))
print('Your number doubled is: ' + str(spam*2))
사용자가 10 진수 (예 : 3.4)를 입력하면 문제가 발생합니다. float 값이되므로 오류가 발생합니다.
Traceback (most recent call last):
File "<pyshell#66>", line 1, in <module>
spam = int(input('choose any number: '))
ValueError: invalid literal for int() with base 10: '3.4'
사용자가 임의의 숫자 (정수 또는 실수 값)를 입력하게하는 간단한 방법이 있습니까?
이것은 파이썬 3이므로 raw_input이 작동하지 않습니다.
'int' 대신'float'을 사용합니까? –