-1

I want to make a terminal kind of thing but after the first terminal response you can't add to it so if you type 'help' in the first one you can't use it after that unless you reload the code, I checked other stack overflow questions but couldn't find the right way I want to put it into my code.

Code: python from time import sleep import sys import time import datetime import os from colorama import Fore, Style, Back

print ("Welcome to Termina, the Repl OS developer shell.\n")

print("If you got here by mistake, don't panic! Just close this tab and carry on.\n")

print ("Type 'help' for a list of commands.\n")

help = "Type 'exit' to leave\nType 'help' for a list of commands\nType 'ip' to print out your IP\n"

termina = input(Fore.YELLOW + Style.BRIGHT+ ""+ Style.RESET_ALL)

ip = "I don't know"

if termina == "help": print(help)

if termina == "ip": print(ip)

while True: if termina == "exit": exit() else: termina = input(Fore.YELLOW + Style.BRIGHT+ ""+ Style.RESET_ALL)


1 Answers1

0

You need all of the code in the while loop. Otherwise you're checking only once if the input is "help".

from time import sleep
import sys
import time
import datetime
import os
from colorama import Fore, Style, Back

print("Welcome to Termina, the Repl OS developer shell.\n")

print("If you got here by mistake, don't panic! Just close this tab and carry on.\n")

print("Type 'help' for a list of commands.\n")

help = "Type 'exit' to leave\nType 'help' for a list of commands\nType 'ip' to print out your IP\n"
ip = "I don't know"

while True:
    termina = input(Fore.YELLOW + Style.BRIGHT + Style.RESET_ALL)

    if termina == "help":
        print(help)
    elif termina == "ip":
        print(ip)
    elif termina == "exit":
        exit()
    else:
        termina = input(Fore.YELLOW + Style.BRIGHT + Style.RESET_ALL)
incapaz
  • 349
  • 1
  • 3
  • 11