Challenge: Make a command line in Python.

Joined
Jan 27, 2025
Messages
9
Reaction score
0
Yes. Here is mine:
print("yPrompt 1.1 O_-")
print("Type 'help' for help")
def inputer():
user_input = (input("C\>"))
def echo():
user_input = (input("Echo:"))
print(user_input)
inputer()
def help():
print('''
echo ;echos a string
help ;shows commands
exit ;exits shell
''')
inputer()
def exit():
print("Exiting...")
user_input = (input("C\>"))
if user_input == "echo":
echo()
elif user_input == "help":
help
elif user_input == "exit":
exit()
else:
print("Invalid Command")
inputer()
#Very buggy cuz I made this from scratch.
#Maybe I should have build it on 1.0...
 
Joined
Jan 5, 2025
Messages
3
Reaction score
0
This would be my one. It's quite a short.

Python:
print('Press \'q\' to quit.')
while True:
    command_input = input(':')
    print(command_input)
    if command_input.lower() == 'q':
      print('You\'ve exited the program.')

The command_input will retain any data (e.g. text and integers) and will simply print it out. However, when someone inserts q, it'll display You've exited the program as a result.

I'm still figuring out how to exit the program once you insert q, do you have any idea how I can do this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,379
Messages
2,571,929
Members
48,767
Latest member
bondarukid

Latest Threads

Top