Sorry if this is a common question, but every solution I've looked up so far doesn't seem to work.
Basically, I want this loop to exit when the user enters "end" but for some reason it won't actually break the loop.
command = input("Enter command: ") + "\r\n"
while(True):
print(command)
if command == "end":
break
else:
tn.write(command.encode("utf-8"))
ret1 = tn.read_until(b"_DNE", timeout = 10)
print(ret1)
command = input("Enter command: ") + "\r\n"
If the user inputs "end" it seems like it ignores the "if" statement and just skips straight to "else"
command == "end\r\n"orcommand == "end\n\r\n"?\r\nto the end of your input string?\r\nas a terminator. That said, I think the best option is probably to define acommunicatefunction that looks like gist.github.com/NotTheEconomist/aa7672106d93bc4079f1