2014-02-18 2 views
0

문자열을 세로로 인쇄해야하는 코드를 작성했습니다. 어떻게해야합니까? 내 수업의 누군가가 다음과 같이 시도해 보았다.python 2.7.6 루프를 사용하면서 세로로 문자열 인쇄

string = raw_input ('Please enter a string. ') 
    while string() true: 
     print string(). 

나는 이것을 시도했지만 작동하지 않았다. 어떤 아이디어? 새 행에 문자열의 각 문자를 인쇄 할 경우

답변

2

, 당신은 문자열을 반복 할 수 있습니다

user_input = raw_input ('Please enter a string. ') # store the string if a variable 
for c in user_input:  # for each character 'c' in the input 
    print(c)    # print it. The print function add a new line character at each call 
관련 문제