나는 다음과 같은 작동하지 않는 이유에 대해 확실하지 오전 :문자열에 return 문을 사용하려면 어떻게해야합니까? - 파이썬
def main():
userInputs()
print(firstColour)
def userInputs():
validColours = ['red', 'green', 'blue', 'yellow', 'magenta','cyan']
while True:
firstColour = input('Enter the 1st colour: ')
secondColour = input('Enter the 2nd colour: ')
thirdColour = input('Enter the 3rd colour: ')
fourthColour = input('Enter the 4th colour: ')
if firstColour in validColours:
if secondColour in validColours:
if thirdColour in validColours:
if fourthColour in validColours:
break
else:
print('Invalid colours.Enter the colours again between red, green, blue, yellow, magenta, cyan')
return firstColour, secondColour, thirdColour, fourthColour
나는 내가 메인 함수를 호출하면 나는 firstColour로 입력 무엇이든, 그것은 인쇄 것이라고 생각?
print (firstcolor) befo 다시 깨기 – Hackaholic
나는 그것을 다른 것으로 사용할 계획이므로 내 userInput 함수에서 인쇄 할 필요없이 인쇄해야한다. 난 그냥 여기에 내 문제를 단순화했습니다 – Konan
다음 firstColor를 반환하거나 사실을 반환 – Hackaholic