Week 6 ends - Python
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import subprocess
|
||||
|
||||
# Save the raw text input first so we don't lose what was typed
|
||||
user_input = input("Input your Command my master: ")
|
||||
|
||||
try:
|
||||
n = int(user_input)
|
||||
print("Integer")
|
||||
except ValueError:
|
||||
# Safely escape single quotes if the user typed any
|
||||
safe_input = user_input.replace("'", "'\\''")
|
||||
|
||||
# Pass the user's exact text directly into cowsay
|
||||
command = f"cowsay '{safe_input}' | lolcat -a -d 50"
|
||||
subprocess.run(command, shell=True)
|
||||
Reference in New Issue
Block a user