As title says... This is just an exercise I'm doing to get better at python. Any help would be greatly appreciated
So this is what i have tried...
read = open('file.txt', 'r')
t = read.read()
for i[0] in t:
if i[0] == 'r' or 'R':
print(i[0])
and...
read = open('file.txt', 'r')
t = read.read()
for i[0] in t:
if i[0] == 'r' or 'R':
print(i[0])
also...
EDIT....... I have been able to find the word with 'R' and 'r' but now I cant figure out how to print the word containing the 'r' and 'R'
for i in t:
if i[0] == 'r' or i[0] == 'R':
print(i)
i tried various types of things and this is what works. I even tried:
if i[0] in ['r', 'R']
and it didnt work for whatever reason.
any help to print the word would be appreciated cause all I get right now is
r R r r R
first one i just get an error saying i is not defined. The second just prints out every word of the document