On Mar 2, 2014 6:30 PM, "Mark Lawrence" <breamore...@yahoo.co.uk> wrote: > > On 02/03/2014 21:10, Tyler Simko wrote: >> >> 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, >>readlines result must be put somewhere >> 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 > > > You haven't stripped the newline before doing the comparison. You also don't have to read the whole file just to compare a specific line. I'll leave you to find out how :) > > -- > My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. > > Mark Lawrence > > --- > This email is free from viruses and malware because avast! Antivirus protection is active. > http://www.avast.com > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor