Search code examples
pythonpython-3.xprintinguser-input

Can one print on the same line after user input?


I am relatively new to python and have to write a code for a "Countdown" based game; the program would basically ask the user for a word, see whether it is located in a file of words, and if it isn't print (directly after the word input by the user) "is invalid".

Here is the portion of code relative to this (I would supply the whole thing but I'm actually in France so it's in French...)

And here is what I see on my screen now, relative to what I have been asked for.

I'm also new to this forum so apologies in advance if this post isn't as polished as others!

Many thanks in advance to anyone willing to help, it's greatly appreciated!


Solution

  • You could do something like this:

    def wordcheck(word):
        if ...:
            return word + " is valid"
    
        else:
            return word + " is invalid"
    
    print("Proposed word: {0} ".format(wordcheck(input())))
    

    Where "if ..." is you checking if the word is valid