Posts

Write on a file

w means write a means append r means read r+ means read + write using w will overwrite the entire file while a will just add data at the end of the existing data  If in name of file u add any number or alphabet it will create another file with just the data u added but only in w mode. Check if file is readable, writeable, use readline and readlines to see the data in the file    f= open ( "sdfsf.html" , "w" ) f.write( " \n Pama 100K" ) f.close()

Building a blind guessing game

secret_word= "carrt" guess= "" guess_count = 0 limit= 3 out_of_guessess= False while guess != secret_word and not (out_of_guessess): if guess_count < limit: guess= input ( "Enter the guess" ) guess_count += 1 else : out_of_guessess= True if out_of_guessess: print ( "Out of guesses" ) else : print ( "Winner" )