This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Using the file school_prompt2.txt, find the number of characters in the file and assign that value to the variable num_char | |
file=open("school_prompt2.txt","r") | |
st=file.read() | |
num_char = 0 | |
for ch in st: | |
num_char+=len(ch) | |
file.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the', 'so', 'it', 'and', 'The'] | |
sent = "The water earth and air are vital" | |
acro = "" | |
words = sent.split() | |
for ch in words: | |
if ch not in stopwords: | |
acro = acro + ch[:2] | |
if ch != words[-1]: | |
acro += ". " |