SlideShare a Scribd company logo
1 of 1
Download to read offline
ThouCount.py
print ("This program will count the number of 'Thou' and 'thou' in ")
print ("the works of Shakespeare.")
thefile = open("Shakespeare.txt")
ThouCount = 0
# for each line in the file
for line in thefile:
# split the line into words
splitline = line.split()
# check to see if word is "Thou" or "thou"
for word in splitline:
if word == ("thou"):
print("Instance of lowercase thou found!")
ThouCount = ThouCount + 1
print ("Count is:", ThouCount)
elif word == ("Thou"):
print ("Instance of Thou with capital 'T' found")
ThouCount = ThouCount + 1
print ("Count is:", ThouCount)
print ("The total count of 'Thou' and 'thou' in all of Shakespeare's works
is:", ThouCount)

More Related Content

More from Matt R

TelephoneInfo-OpenInteraction
TelephoneInfo-OpenInteractionTelephoneInfo-OpenInteraction
TelephoneInfo-OpenInteractionMatt R
 
PhoneCallTools
PhoneCallToolsPhoneCallTools
PhoneCallToolsMatt R
 
LaptopTrustIssues
LaptopTrustIssuesLaptopTrustIssues
LaptopTrustIssuesMatt R
 
Interactions
InteractionsInteractions
InteractionsMatt R
 
Interaction-Incident
Interaction-IncidentInteraction-Incident
Interaction-IncidentMatt R
 
FoundationProcess
FoundationProcessFoundationProcess
FoundationProcessMatt R
 
FindStaffPerson
FindStaffPersonFindStaffPerson
FindStaffPersonMatt R
 
ChangesChecklist
ChangesChecklistChangesChecklist
ChangesChecklistMatt R
 
bigalsnetwork
bigalsnetworkbigalsnetwork
bigalsnetworkMatt R
 
DateDiffQuery
DateDiffQueryDateDiffQuery
DateDiffQueryMatt R
 
DualScreenDualCPU
DualScreenDualCPUDualScreenDualCPU
DualScreenDualCPUMatt R
 
LoyalKasparBackupPlanProposal
LoyalKasparBackupPlanProposalLoyalKasparBackupPlanProposal
LoyalKasparBackupPlanProposalMatt R
 
MattSampleDatabase
MattSampleDatabaseMattSampleDatabase
MattSampleDatabaseMatt R
 
PythonPythagoreanTheorem
PythonPythagoreanTheoremPythonPythagoreanTheorem
PythonPythagoreanTheoremMatt R
 
Sample Website
Sample WebsiteSample Website
Sample WebsiteMatt R
 
XenAppDoc
XenAppDocXenAppDoc
XenAppDocMatt R
 
SpecNetworkMap
SpecNetworkMapSpecNetworkMap
SpecNetworkMapMatt R
 
SpecWiringSchematicFinal (1)
SpecWiringSchematicFinal (1)SpecWiringSchematicFinal (1)
SpecWiringSchematicFinal (1)Matt R
 
How-To-ID-Application
How-To-ID-ApplicationHow-To-ID-Application
How-To-ID-ApplicationMatt R
 

More from Matt R (20)

TelephoneInfo-OpenInteraction
TelephoneInfo-OpenInteractionTelephoneInfo-OpenInteraction
TelephoneInfo-OpenInteraction
 
PhoneCallTools
PhoneCallToolsPhoneCallTools
PhoneCallTools
 
LaptopTrustIssues
LaptopTrustIssuesLaptopTrustIssues
LaptopTrustIssues
 
Interactions
InteractionsInteractions
Interactions
 
Interaction-Incident
Interaction-IncidentInteraction-Incident
Interaction-Incident
 
FoundationProcess
FoundationProcessFoundationProcess
FoundationProcess
 
FindStaffPerson
FindStaffPersonFindStaffPerson
FindStaffPerson
 
ChangesChecklist
ChangesChecklistChangesChecklist
ChangesChecklist
 
3tabs
3tabs3tabs
3tabs
 
bigalsnetwork
bigalsnetworkbigalsnetwork
bigalsnetwork
 
DateDiffQuery
DateDiffQueryDateDiffQuery
DateDiffQuery
 
DualScreenDualCPU
DualScreenDualCPUDualScreenDualCPU
DualScreenDualCPU
 
LoyalKasparBackupPlanProposal
LoyalKasparBackupPlanProposalLoyalKasparBackupPlanProposal
LoyalKasparBackupPlanProposal
 
MattSampleDatabase
MattSampleDatabaseMattSampleDatabase
MattSampleDatabase
 
PythonPythagoreanTheorem
PythonPythagoreanTheoremPythonPythagoreanTheorem
PythonPythagoreanTheorem
 
Sample Website
Sample WebsiteSample Website
Sample Website
 
XenAppDoc
XenAppDocXenAppDoc
XenAppDoc
 
SpecNetworkMap
SpecNetworkMapSpecNetworkMap
SpecNetworkMap
 
SpecWiringSchematicFinal (1)
SpecWiringSchematicFinal (1)SpecWiringSchematicFinal (1)
SpecWiringSchematicFinal (1)
 
How-To-ID-Application
How-To-ID-ApplicationHow-To-ID-Application
How-To-ID-Application
 

ThouCount

  • 1. ThouCount.py print ("This program will count the number of 'Thou' and 'thou' in ") print ("the works of Shakespeare.") thefile = open("Shakespeare.txt") ThouCount = 0 # for each line in the file for line in thefile: # split the line into words splitline = line.split() # check to see if word is "Thou" or "thou" for word in splitline: if word == ("thou"): print("Instance of lowercase thou found!") ThouCount = ThouCount + 1 print ("Count is:", ThouCount) elif word == ("Thou"): print ("Instance of Thou with capital 'T' found") ThouCount = ThouCount + 1 print ("Count is:", ThouCount) print ("The total count of 'Thou' and 'thou' in all of Shakespeare's works is:", ThouCount)