Python Forum
New in Python. Have question on my code.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New in Python. Have question on my code.
#3
  • create another variable at start to keep count of total number of words total_words = 0
  • strip line feeds from lines before split,
    lines = lines.strip()
  • split lines into slines
    Use a new name saving original for printing
  • calculate line length of split line
  • add line length to total_words
  • print line number, length and lines
  • Continue loop
  • after loop (not part of loop) calculate and print average line length
Reply


Messages In This Thread
RE: New in Python. Have question on my code. - by Larz60+ - Sep-02-2020, 03:34 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Question re: running code in Editor (i.e. Atom) vs Python interpreter rok 3 2,451 Jun-29-2020, 09:20 PM
Last Post: bowlofred
  Newb question: Debugging + Linting Python in Visual Studio Code Drone4four 1 2,448 Apr-15-2019, 06:19 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020