[Tutor] Question

Lucia Stockdale Lucia.Stockdale at mggs.vic.edu.au
Thu Aug 21 05:03:03 CEST 2014


Hi everyone,

I have been writing a program to print words backwards until an an empty line of input is entered,
but after I put in the input it comes up with TypeError.

This is my goal:

Line: hello world
olleh dlrow
Line: extra
artxe
Line: i love python
i evol nohtyp
Line:

This is my current code:

line = input('Line: ')
while line != '':
  line = line[len(line):0:-1]
  line = line.split()
  line = line.reverse()
  line = (' '.join(line))
  print(line)


Thanks
Lucia

This email is intended for the use of the named individual or entity and may contain confidential and privileged information. Any dissemination, distribution or copying by anyone other than the intended recipient of this email is strictly prohibited. Confidentiality and legal privilege are not waived or lost as a result of mistaken delivery. Attachments are opened and transmitted at the user's own risk. Any representations or opinions expressed are those of the individual sender, and not necessarily those of Melbourne Girls Grammar.


More information about the Tutor mailing list