Category : break

I was making an program in Python and I needed to break out of if else lop without breaking out of while loop. Current code (incomplete code just for example. Not full code.): class foo: def __init__(self, time1, link) while self.isItNow == False: self.current_time = self.now.strftime("%H:%M") print(self.current_time) if str(self.current_time) == self.time1: webbrowser.open(self.link, new=1) self.isItNow = ..

Read more

I wanted make window which will reappear if closed but will only close if user presses a button. I tried so many times but cant make. Plz help. from Tkinter import * x=’y’ while x!=’break’: def something(x): x=’break’ root=tkinter.Tk() button=tkinter.Button(root, text=’Break’, command=lambda:something(x)) button.pack() root.mainloop() print(‘done’) Source: Python..

Read more

I have a small doubt about an online assignment of mine that I completed. So the assignment requires me to open a txt file and make all the characters upper case. fh = open(f) fhand=fh.read() for line in fhand: line=fhand.rstrip() line=fhand.upper() print(line) break this is the code that I used. If I don’t add the ..

Read more

I’d like to know, if I have more than one if statement, is it possible to break out of all these ifs to ask again one of the three if statement (Gent, Madam, Daughter) ? character = {‘Gent’: False, ‘Madam’: False, ‘Daughter’: False} print(character) character[random.choice(list(character.keys()))] = True print(character) print("Starting up …") if character[‘Gent’] == True: ..

Read more