#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http 제목문자열 뒤집기 프로그램 질문2019-03-13 01:23작성자SW19Step_05_String의 문자열 뒤집기 프로그램에 질문이 있습니다.저는 두 가지 방법으로 풀어 오류가 났습니다.1.def reverseString(ValR): print(ValR[4],ValR[3],ValR[2],ValR[1],ValR[0],sep="") return2.def reverseString(ValR): print(ValR[4],sep="",end="") print(ValR[3],sep="",end="") print(ValR[2],sep="",end="") print(ValR[1],sep="",end="") print(ValR[0],sep="") return두가지 경우 모두assert reverseString("hello") == "olleh"assert reverseString("world") == "dlrow"assert reverseString("12345") == "54321"를 실행했을 때olleh --------------------------------------------------------------------------- AssertionError Traceback (most recent call last) <ipython-input-77-80fe570984f9> in <module> ----> 1 assert reverseString("hello") == "olleh" 2 assert reverseString("world") == "dlrow" 3 assert reverseString("12345") == "54321" AssertionError: 과 같은 오류가 발생했습니다.이러한 오류는 왜 발생하는 건지 궁금합니다.(+)그리고 추가적으로 인터넷 검색을 통해 찾아본 해결법으로는3. print(ValR[ ::-1]4. print(reversed(ValR)) 이 있었습니다. 하지만 두가지 방법은1.olleh --------------------------------------------------------------------------- AssertionError Traceback (most recent call last) <ipython-input-12-80fe570984f9> in <module> ----> 1 assert reverseString("hello") == "olleh" 2 assert reverseString("world") == "dlrow" 3 assert reverseString("12345") == "54321" AssertionError: 2.<reversed object at 0x000002667BAE4B38> --------------------------------------------------------------------------- AssertionError Traceback (most recent call last) <ipython-input-10-80fe570984f9> in <module> ----> 1 assert reverseString("hello") == "olleh" 2 assert reverseString("world") == "dlrow" 3 assert reverseString("12345") == "54321" AssertionError: 과 같은 오류가 발생했습니다.어떻게 코드를 짜야 오류가 발생하지 않고 프로그램을 완성할 수 있나요? 목록수정삭제답변글쓰기 댓글 [0] 댓글작성자(*)비밀번호(*)내용(*) 댓글 등록 더보기이전2019년 1학기 소융학과 학부생 멘토링drsungwon 2019-03-13다음함수의 리턴값에 대한 이해가 필요합니다drsungwon 2019-03-13 Powered by MangBoard | 워드프레스 쇼핑몰 망보드