Also, we tried removing the raw input, but it wouldn't print correct On Sat, Jun 18, 2011 at 9:55 PM, aditya <nauty.m...@gmail.com> wrote:
> > > On Sat, Jun 18, 2011 at 9:35 PM, Jacob Bender <benderjaco...@gmail.com>wrote: > >> Dear Tutors, >> >> Alright, I'm using linux (ubuntu) and I took all of your advice and I got >> something that works and doesn't work at the same time. Here's the source >> code for my two programs called Lock and Key: >> >> *Lock.py: * >> >> password = "a" >> >> psswd_try = raw_input("What's the password? ") >> >> if psswd_try == password: >> print "correct!!!" >> raw_input() >> else: >> print "wrong" >> raw_input() >> * >> * > > Why do you need to call raw_input() again? You are giving the input only > once so remove raw_input() from both if and else , that should do the work > > > >> *Key.py*: >> >> import sys >> >> sys.stdout.write("a") >> >> In the linux terminal I ran this command(they were both in my home folder, >> so no directories were needed): >> >> python Key.py | python Lock.py >> >> And all went well except for an EOF error caused by the raw_input inside >> the "if" statement in my Lock program. However I did get it to print >> "correct", so I know sys.stdout.write() works for what I want it to, but I >> don't want the EOF error. Here's the output: >> >> Traceback (most recent call last): >> File "Lock.py", line 7, in <module> >> raw_input() >> EOFError: EOF when reading a line >> >> Please help me get rid of it because I couldn't find a sys.stdout.close() >> command or any other std command that would help. >> >> Thanks! >> >> >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> http://mail.python.org/mailman/listinfo/tutor >> >> > > > -- > Regards > Aditya > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor