'How would i get this newcommands.index work?

What I'm trying to do is get the position of the users input so if they recall a command it will return the value but it doesn't work for some reason idk why I've tried everything I know please help.

#new file
#new untitled file
args = []
newcommands = []
import time,random,os,sys
commands = ["help","version","python"]
while True:
    
    command = input(">")
    if command not in commands:
        print("That command does not exist")
    if command == "help":
        print(commands)
    if command == "version":
        print("Version = 0.0.1")
    if command == "python":
        print("Type exit to exit the python interperter")
        os.system("python")
    if command == "DM ME A COMMAND":
        pass
    if command == "New":
        if len(newcommands) != 5:
         name = input("Enter a name: ")
         text= input("Enter text for the function: ")
         q = newcommands.append(name)
         args.append(text)
        
    if q ==  newcommands.index(0):
         print(args.index(0))
    if q ==  newcommands.index(1):
             print(args.index(1))
    if q ==  newcommands.index(2):
                print(args.index(2))
    if q ==  newcommands.index(3):
             print(args.index(3))
    if q ==  newcommands.index(4):
             print(args.index(4))
    if q ==  newcommands.index(5):
             print(args.index(5))        



Solution 1:[1]

i dont know what are you trying to do but seems your logic is more than i could understand

because you try to enter New command which is not on the list it means it will never execute the if condition for the "New"

and if that's not all you also try to get command line args which will never given by the user.

so basically please give the description of you question

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Krunal Akbari