-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathday-15.py
More file actions
33 lines (29 loc) · 740 Bytes
/
day-15.py
File metadata and controls
33 lines (29 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/python3
import sys
class Node:
def __init__(self,data):
self.data = data
self.next = None
class Solution:
def display(self,head):
current = head
while current:
print(current.data,end=' ')
current = current.next
def insert(self,head,data):
#Complete this method
if head is None:
head = Node(data)
else:
curr = head
while curr.next:
curr = curr.next
curr.next = Node(data)
return head
mylist= Solution()
T=int(input())
head=None
for i in range(T):
data=int(input())
head=mylist.insert(head,data)
mylist.display(head);