[Tutor] Equality Check.

Tyler Simko tsimko at princeton.edu
Sun Mar 2 22:10:02 CET 2014


Hi all! 

I'm embarrassingly new at Python, so please forgive my probably simple mistakes. 

So I called readlines() on a file, and I'm wondering how I can check the equality of a specific line with a raw_input set variable as a condition. For example,

file = open('filename.txt,' 'r')
file.readlines()
variable_name = raw_input()
if file[2] == variable_name:
     #whatever 

This approach hasn't worked so far, does anyone have any tips? Thanks so much!!

-Tyler 


More information about the Tutor mailing list