Trying to put error messages if index is out of bound, named removed doesn't exist, limit adding names to 5 and displaying names individually

newbie
student = [] 
opt = 1
while(opt!=0):
    print("1.Add | 2.Edit | 3.Delete | 4:Display | 0:Exit")
    opt = int(input("option:")
    if(opt==1):
        student.append(input("addname:"))
    elif(opt==2):
        edit = int(input("index to edit:"))
        student[edit] = input("Updated name:")
    elif(opt==3):
        student.remove(input("Enter Name:"))
    elif(opt==4):
        for x in range(0,len(student)):
            print(student[(len(student)-1)-x])

so I'm trying to create a code where it will put an error message if index to edit is out of bound, if the named remove doesn't exist and limiting the add name just up to 5. as well displaying name individual but at my opt==4 it's displaying them backward and if I removed the negative sign it comes out as an error saying perhaps I have forgotten a comma.

AI - 2821
student = [] 
opt = 1
while(opt!=0):
    print("1.Add | 2.Edit | 3.Delete | 4:Display | 0:Exit")
    opt = int(input("option:")
    if(opt==1):
         if len(student) < 5:
            student.append(input("addname:"))
    elif(opt==2):
        edit = int(input("index to edit:"))
        if edit < len(student):
            student[edit] = input("Updated name:")
        else :
            print ("Index out of bound")
    elif(opt==3):
        student.remove(input("Enter Name:"))
    elif(opt==4):
        for x in range(0,len(student)):
            print(student[x])

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Trying to get to grips with C++ and cant work out why this doesn't print out the names of the vector<string> entries

Specific named range does not exist in .Names

String index out of bound error

Rails 5 - Displaying error messages

Row names column can't be removed in R

Why i get the warning message "Removed /IDTree from /Names dictionary, doesn't belong there"?

Trying to use WithArg in GMock code; error says it doesn't exist

Getting a "File doesn't exist" error when trying to create a file

Error Index out of Bound when trying to write data to new .txt file (Python)

Octave index out of bound error. Can't figure out why

Issue when adding a column in WooCommerce admin orders displaying product names

Why doesn't R change column names when I am trying to change all column names based on a single row?

Trying to pull out names of lists which have a low value. Can't get logic to work

Searching user names in multiple files and print if it doesn't exist using bash script

Best way to deal with index out of bound error

Arraylist error index out of bound or it is null

Cannot sort the array , index out of bound error

Android Index out of Bound error inside Recyclerview

Index out of bound error with TypeConverter implementation

Getting index out of bound error in Python

Put a random generator script on page - it works. Add another one with different names - doesn't work

Strange EclipseLink error - won't allow a table named 'User', other names work fine

List index out of range error when getting column names from dict keys

Displaying names onmouseover

Dynamically displaying the column names

Finding and Displaying Unique Names

Won't print out names help please

Displaying Names section wise in AddressBook Alphabetically in iOS 5 with use of CFArray

JAVA-Why/Where am I getting an Array Index out of bound error while trying to covert an infix to post fix expression?

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive