new commit
This commit is contained in:
29
userinput.py
Normal file
29
userinput.py
Normal file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
def main():
|
||||
print("Interactive Task Loop - Enter your input (type 'stop' to exit):")
|
||||
|
||||
while True:
|
||||
try:
|
||||
user_input = input("\n> ").strip()
|
||||
|
||||
if user_input.lower() == "stop":
|
||||
print("Exiting the interactive loop. Goodbye!")
|
||||
break
|
||||
|
||||
if not user_input:
|
||||
print("Please enter a command or 'stop' to exit.")
|
||||
continue
|
||||
|
||||
print(f"User input received: {user_input}")
|
||||
return user_input
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\n\nInterrupted by user. Exiting...")
|
||||
break
|
||||
except EOFError:
|
||||
print("\n\nEnd of input. Exiting...")
|
||||
break
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user