import random


def getRandomString(leng):

    cheese=''

    for i in range(int(leng)):

        word=random.choice(string)

        cheese=cheese+word

    return cheese


leng=input()

string='a b c d e f g h i j k l m n o p q r s t u v w x y z'.split()

print(getRandomString(leng))


이렇게 하면 실행이 되는데 저기 cheese=''을 leng=input() 밑으로 빼면 실행이 안 되거든요. 지역변수 전역변수 관련된 것 같은데 이유를 모르겠는데 왜 그럼. 파이썬임다