Nice Format For Chatting Server - Python | Sololearn: Learn to code for FREE!

0

Nice Format For Chatting Server - Python

Hey, Do any of you have a nice way/idea to make this format look normal? in my server people can send and receive text in parallel - meaning: threads. if i take inpute like so: input('You> ') and receive data like so: print(data) # data will look like: username> text text text how can i make it nice so everything will be in a new line? i tried a way that the input is: input('You> ') and the receiveing is: print(f'\n{username}> {number}', end='\nYou> ') thats the best i could do... can anyone help? look at your previous codes mybe and it might help... the threads mess eveything up...

4/6/2021 12:50:41 PM

Yahel

9 Answers

New Answer

0

I had some code that did this once, but the prompt definitely wasn’t in that print statement.

0

You can’t really use the input function as far as I know. Use the select module.

0

Wilbur Jaywright may I have an example please? Isn't the select module just for the server-side? To allow serving of multiple clients?

0

On linux at least, the select module checks if a file or I/O socket is ready for reading.

0

Wilbur Jaywright yeah, I know.. on on windows though... but what about the original question? I spent too much time on this ngl lol

0

I… wasn’t entirely sure I understood the original question.

0

Hold on a minute! you have the prompt text in both the input and the print statement. Take it out of the print statement.

0

Wilbur Jaywright I know... without it it still doesn't work.. the threads mess it up...

0

What exactly happens?