Nov-04-2019, 11:38 AM
Some observations about your code:
- input is string, so no need to use str() for converting
- no need to define n before while loop. Use instead 'while True' and break
- use Larz60+ advice - append user answers to list and print out longest
As this is homework I provide 3.8-only compatible solution which probably will not pass automagic check but gives general idea:
- input is string, so no need to use str() for converting
- no need to define n before while loop. Use instead 'while True' and break
- use Larz60+ advice - append user answers to list and print out longest
As this is homework I provide 3.8-only compatible solution which probably will not pass automagic check but gives general idea:
values = [] # list to collect user entered strings while (answer := input('Enter input: ')) != '': # while loop which assigns user input to answer and checks equality to '' values.append(answer) # appends answers to values list print(f'Longest input was {max(values, key=len)}') # prints out longest element in values list
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.