Phone

+919997782184

Email

support@roboticswithpython.com

Geeks of Coding

Join us on Telegram

Home Forums Assignment courserra Python for Everybody – Specialization Programming for Everybody (Getting started with Python) Assignment 2.1, Programming for Everybody (Getting started with Python)

Viewing 0 reply threads
  • Author
    Posts
    • #866
      Abhishek TyagiAbhishek Tyagi
      Keymaster

      2.1- You can write any code you like in the window below. There are three files loaded and ready for you to open if you want to do file processing: “mbox-short.txt”, “romeo.txt”, and “words.txt”.

      fh = open("words.txt", "r")
      
      count = 0
      for line in fh:
          print(line.strip())
          count = count + 1
      
      print(count,"Lines")
      
      gh = open("romeo.txt", "r")
      
      count = 0
      for line in gh:
          print(line.strip())
          count = count + 1
      
      print(count,"Lines")
      
      kh = open("mbox-short.txt", "r")
      
      count = 0
      for line in kh:
          print(line.strip())
          count = count + 1
      
      print(count,"Lines")
Viewing 0 reply threads
  • You must be logged in to reply to this topic.