I would like some advice as to how to write my wc program. Program should accept a file name as input and then print three numbers showing the count of lines, words and characters in the file. Chapter 4 question 15 of zelles introduction to python
huglybits
0
Newbie Poster
Recommended Answers
Jump to PostAssuming the question does not want a count of unique words/characters this should do it:
open the file for reading number of words,characters, lines = 0 while a line can be read from the file read a line into a string number of lines + = 1 …
Jump to PostProgram should accept a file name as input
Do you want the program to ask the user to key in a file name, or do you want to provide it as an argument when the program is called, or do you want to use a GUI that allows the user …
Jump to PostYou can use
number = number + 1
or
number += 1
All 10 Replies
bgeddy
0
Newbie Poster
huglybits
0
Newbie Poster
woooee
814
Nearly a Posting Maven
huglybits
0
Newbie Poster
ZZucker
342
Practically a Master Poster
bgeddy
0
Newbie Poster
huglybits
0
Newbie Poster
misty_mirage
0
Newbie Poster
rysin
0
Light Poster
misty_mirage
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.