편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2020.04.22

    파이썬 도와주세요! TypeError: unsupported operand type(s) for +: 'int' and 'str'


    numbers = (1,2,3,4,5,6,7,8,9)
    for list in numbers :
        if list==1 :
            print("1" + "st")
        elif list==2 :
            print("2" + "nd")
        elif list==3 :
            print("3" + "rd")
        else :
            print(list + "th")
    

    이렇게 하면 TypeError: unsupported operand type(s) for +: 'int' and 'str' 해당 오류가 나옵니다. 결과를

    1st
    2nd
    3rd
    4th
    5th
    6th
    7th
    8th
    9th 
    

    이렇게 나오게 하고 싶은데 어떻게 해야할까요?

  • 프로필 알 수 없는 사용자님의 편집
    날짜2020.04.22

    파이썬 도와주세요!


    numbers = (1,2,3,4,5,6,7,8,9) for list in numbers : if list==1 : print("1" + "st") elif list==2 : print("2" + "nd") elif list==3 : print("3" + "rd") else : print(list + "th")

    이렇게 하면 TypeError: unsupported operand type(s) for +: 'int' and 'str' 해당 오류가 나옵니다. 결과를 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 이렇게 나오게 하고 싶은데 어떻게 해야할까요?