1

I am wondering if it is possible in Python to assign the value from an input statement to a variable, while making the presence of input the condition of a while loop.

What I tried:

while w = input("Enter word to define:\n").lower():
    output = define_word(w)
    if type(output) = list:
        for item in output:
            print(item)

What I got:

File "main.py", line 23
while w = input("Enter word to define:\n").lower():
        ^
SyntaxError: invalid syntax

I am curious if there is a way of assigning user input to a variable provided there is any user input instead of repeating the same input statement within the loop and assigning it to a variable separately. Thank you, criticism is welcome, this is my first question on Stackoverflow ever...

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
jan kowal
  • 29
  • 1

0 Answers0