Study/PYTHON
[나도코딩] 파이썬 강의_퀴즈2
chanzae
2021. 10. 9. 15:02
1. print()에 바로 randint() 함수를 집어넣음 > Error > random 모듈을 불러왔어야 함.
print("오프라인 스터디 모임 날짜는 매월 "+ randint(4,28) +"일로 선정되었습니다.")
2. 모듈을 불러옴> Error > random 모듈과 math모듈 착각함
from math import *
print("오프라인 스터디 모임 날짜는 매월 "+ randint(4,28) +"일로 선정되었습니다.")
from math import *
date = print(randint(4, 28))
print("오프라인 스터디 모임 날짜는 매월 "+date+"일로 선정되었습니다.")
3. random모듈로 수정하고, 변수를 설정함 > Error > 변수 설정시 print() 필요없음.
from random import *
date = print(randint(4, 28))
print("오프라인 스터디 모임 날짜는 매월 "+date+"일로 선정되었습니다.")
해결)
from random import *
date = randint(4, 28)
print("오프라인 스터디 모임 날짜는 매월 " + str(date) + "일로 선정되었습니다.")
올바른 모듈, 변수 설정 필요, print()에서 숫자 함수 출력시 str()로 감싸줘야 함.
반응형