편집 기록

편집 기록
  • 프로필 엽토군님의 편집
    날짜2020.05.20

    리스트를 중첩? 하는 방법이 뭐예요..?


    import collections
    import operator
    Student = collections.namedtuple("Student", "name stdid grade" )
    e=int(input("Input loop count: "))
    list=[]
    for list in range (e):
    
        name1=input("Input name: ")
        stdid1 =int(input("Input student id: "))
        grade1= int(input("Input grade: "))
    
    
        std=Student(name=name1, stdid=stdid1, grade=grade1)
    
    list=sorted(list,key = attrgetter("id"))
    print("===============================")
    print(std)
    

    e에 입력한 숫자만큼 식을 반복하는데 list안에 name1, stdid1, grade1을 마지막으로 입력한 값들만 포함이 돼요. 어떻게 해야 그전에 입력한 숫자들도 저장이 될까요...? 그리고 attrgetter가 정의되지 않았다고 에러가 나는데 import operator하면 attrgetter은 정의하지 않아도 되는거 아니에요?

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

    리스트를 중첩? 하는 방법이 뭐예요..?


    import collections import operator Student = collections.namedtuple("Student", "name stdid grade" ) e=int(input("Input loop count: ")) list=[] for list in range (e):

    name1=input("Input name: ")
    stdid1 =int(input("Input student id: "))
    grade1= int(input("Input grade: "))
    
    
    std=Student(name=name1, stdid=stdid1, grade=grade1)
    

    list=sorted(list,key = attrgetter("id")) print("===============================") print(std)

    e에 입력한 숫자만큼 식을 반복하는데 list안에 name1, stdid1, grade1을 마지막으로 입력한 값들만 포함이 돼요. 어떻게 해야 그전에 입력한 숫자들도 저장이 될까요...? 그리고 attrgetter가 정의되지 않았다고 에러가 나는데 import operator하면 attrgetter은 정의하지 않아도 되는거 아니에요?