Sort by

recency

|

2868 Discussions

|

  • + 0 comments

    if name == 'main': l=[] l2=[] N=int(input()) for _ in range(N): l.append(input().split()) #print(l) for i in l: match i[0]: case "append": a,b=i l2.append(int(b)) case "insert": a,b,c=i l2.insert(int(b),int(c)) case "remove": a,b=i l2.remove(int(b)) case "pop": l2.pop() case "reverse": l2.reverse() case "sort": l2.sort() case "print": print(l2)

  • + 0 comments

    if name == 'main': N = int(input()) result=[] for i in range(N): commands= input().split()

        match commands[0]:
            case "insert":
                result.insert(int(commands[1]),int(commands[2]))
            case "print":
                print(result)
            case "remove":
                result.remove(int(commands[1]))
            case "append":
                result.append(int(commands[1]))
            case "sort":
                result.sort()
            case "pop":
                result.pop()
            case "reverse":
                result.reverse()
    
  • + 0 comments
    if __name__ == '__main__':
        N = int(input())
        res = []
        for i in range(N):
            row = input().split()
            
            match row[0]:
                case "append":
                    res.append(int(row[1]))
                case "reverse":
                    res.reverse()
                case "sort":
                    res = sorted(res)
                case "insert":
                    res.insert(int(row[1]), int(row[2]))
                case "print":
                    print(res)
                case "remove":
                    res.remove(int(row[1]))
                case "pop":
                    res.pop()
                    
    
  • + 0 comments
    N = int(input())
        List = []
        
        for i in range(N):
            command = input().split()
    
            if command[0] == "insert":
                List.insert(int(command[1]),int(command[2]))
            elif command[0] == "print":
                print(List)
            elif command[0] == "remove":
                List.remove(int(command[1]))
            elif command[0] == "append":
                List.append(int(command[1]))
            elif command[0] == "sort":
                List.sort()
            elif command[0] == "pop":
                List.pop()
            elif command[0] == "reverse":
                List.reverse()
            else:
                exit()
                
    
  • + 0 comments

    if name == 'main': N = int(input()) l = list()

    for _ in range(N):
        command= input().split()
    
        if command[0]=="insert":
            i = int(command[1])
            e = int(command[2])
            l.insert(i,e)
    
        elif command[0]=="print":
            print(l) 
    
        elif command[0]=="remove":
            l.remove(int(command[1])) 
    
        elif command[0]=="append":
            l.append(int(command[1])) 
    
        elif command[0]=="sort":
            l.sort() 
    
        elif command[0]=="pop":
            l.pop()
    
        elif command[0]=="reverse":
            l.reverse()