0% found this document useful (0 votes)
42 views3 pages

Linked List Operations Guide

The document demonstrates how to perform operations on a linked list using Python. It initializes a linked list with three elements - India, Japan, and America. It then enters a while loop that prompts the user to select an operation - add, remove, replace, search, or exit. Based on the selection, it performs the operation, such as inserting Russia at the beginning or replacing Japan with Indonesia. It prints the updated list after each operation.

Uploaded by

Mayank Sagwekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views3 pages

Linked List Operations Guide

The document demonstrates how to perform operations on a linked list using Python. It initializes a linked list with three elements - India, Japan, and America. It then enters a while loop that prompts the user to select an operation - add, remove, replace, search, or exit. Based on the selection, it performs the operation, such as inserting Russia at the beginning or replacing Japan with Indonesia. It prints the updated list after each operation.

Uploaded by

Mayank Sagwekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

4/13/23, 4:52 AM Copy of Linked Lists.

ipynb - Colaboratory

l1 = []
[Link]("India")
[Link]("Japan")
[Link]("America")
print("The existing list = ",l1)

choice = 0
while choice <5:
  print('Linked list operation')
  print('1. Add element')
  print('2. Remove element')
  print('3. Replce element')
  print('4. search element')
  print('5. Exit')
  choice = int(input('your choice'))

  if choice==1:
    element=input('Enter element: ')
    pos=int(input('At what position'))
    [Link](pos,element)
  elif choice==2:
    try:
      element=input('Enter element: ')
      [Link](element)
    except ValueError:
      print('Element not found')
  elif choice==3:
    element=input('Enter element: ')
    pos=int(input('At what position'))
    [Link](pos)
    [Link](pos,element)
  elif choice==4:
    element=input('Enter element:')
    try:
      pos=[Link](element)
      print('element found at position:',pos)
    except ValueError:
      print("element not found")
  else:
    break
  print('List= ',l1)

[Link] 1/3
4/13/23, 4:52 AM Copy of Linked [Link] - Colaboratory

The existing list = ['India', 'Japan', 'America']


Linked list operation
1. Add element
2. Remove element
3. Replce element
4. search element
5. Exit
your choice1
Enter element: Russia
At what position0
List= ['Russia', 'India', 'Japan', 'America']
Linked list operation
1. Add element
2. Remove element
3. Replce element
4. search element
5. Exit
your choice2
Enter element: Russia
List= ['India', 'Japan', 'America']
Linked list operation
1. Add element
2. Remove element
3. Replce element
4. search element
5. Exit
your choice3
Enter element: Indonesia
At what position1
List= ['India', 'Indonesia', 'America']
Linked list operation
1. Add element
2. Remove element
3. Replce element
4. search element
5. Exit
your choice4
Enter element:India
element found at position: 0
List= ['India', 'Indonesia', 'America']
Linked list operation
1. Add element
2. Remove element
3. Replce element
4. search element
5. Exit
your choice5
[Link] 2/3
4/13/23, 4:52 AM Copy of Linked [Link] - Colaboratory

Colab paid products - Cancel contracts here

[Link] 3/3

You might also like