Skip to content

Commit 84604f3

Browse files
authored
Update Single-linked-list-operations.py
1 parent a76ab9d commit 84604f3

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Data Structures/Linked Lists/Singly Linked List/Single-linked-list-operations.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,25 @@ def removeval(self, value):
115115

116116
if __name__ == '__main__':
117117
node1 = LinkedList()
118-
node1.insert_values(["python", "C++", "C", "Java"])
119-
node1.insert_at(1, "Javascript")
120-
node1.remove_at(2)
118+
ins = list(input("Enter a values to be inserted by giving space[eg: python c++ java] : ").rstrip().split())
119+
node1.insert_values(ins)
120+
node1.print()
121+
ind = int(input("Enter the index to be added: "))
122+
val = input('Enter the value: ')
123+
node1.insert_at(ind, val)
124+
node1.print()
125+
remm = int(input('Enter the index to be removed: '))
126+
node1.remove_at(remm)
121127
node1.print()
122128
remval = input('Enter the value to be removed: ')
123129
node1.removeval(remval)
124130
node1.print()
125-
node1.insert_values([45, 7, 12, 567, 99])
126-
node1.insert_at_end(67)
131+
inss = list(input("Enter a values to be inserted by giving space[eg: 45 30 22] : ").rstrip().split())
132+
node1.insert_values(inss)
133+
node1. print()
134+
inend = int(input('Enter the number to be inserted at the end: '))
135+
node1.insert_at_end(inend)
127136
node1.print()
128-
remval1 = int(input())
137+
remval1 = input('Enter the value to be removed: ')
129138
node1.removeval(remval1)
130139
node1.print()
131-

0 commit comments

Comments
 (0)