Question

python For this lab you are being provided with a file named lastnames.txt. Your mission is...

python

For this lab you are being provided with a file named lastnames.txt. Your mission is determine how many last names in this file are longer than XXX characters (where XXX is a number you read from the user).

So your program will need to:

  • Take in a number from the user to use for filtering
  • Read data from the file
  • Process the data from the file to determine how many last names are longer than input number
  • Print the resulting last name count to the screen
0 0
Add a comment Improve this question Transcribed image text
Answer #1

f=open("lastnames.txt","r")

n=int(input("Enter last name count"))

count=0

for x in f:

  if len(x)>n:

    count=count+1

print(count,"names are longer than length ",n)

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
python For this lab you are being provided with a file named lastnames.txt. Your mission is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT