0

Dear friends i am trying to access the flash drive when i select option 2 on the menu list, however i always get an error. could someone help me please.i am getting directories that are not the f: drive which is where the flash drive is installed. Your support will be highly appreciated

    #This is tutorial on operating system managers
#====================================================
#MENU FUNCTIONS
 #====================================================

def print_menu(): 
    print('Welcome,here is a briefly operating system management tutorial:')

    #begin of choices

    print('1. Process Management')
    print('2. File Management')
    print('3. Device Management')
    print('4. Memory Management')
    print('5. Back')
    print('6. Exit')
    print()

    numbers={}
    menu_choices=0
    print_menu()



    while menu_choices !=6:

    menu_choices=int(input("Type in a number between (1-6):"))

    if menu_choices==1:
        print ("Process Management:")
        print (">>")
        print (">>")
        print()

    elif menu_choices==2:
        import os
        print("File Management")
        print(" Insert a USB in a disk F: ")
        print( os.listdir('/'))


    elif menu_choices==3:  
        print("Device Management")
        print (" >> ")
        print (" >> ")
        print()

    elif menu_choices==4:
        print("Memory Management")
        print(" >> ")
        print(" >> ")
        print()

    elif menu_choices==5:
        print_menu()  


    elif menu_choices==6:
         print("Goodbye")    
         print()    


    else:
        menu_choices !=""
        print ('Invalid selection, please try again.')
        print_menu()
        print()

1 Answer 1

2

If you don't change to the F: drive first, os.listdir will just list files on the current drive.

os.chdir('F:')

Sign up to request clarification or add additional context in comments.

1 Comment

or just specify it in the listdir, as os.listdir("F:\\")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.