Category : if-statement

This is my code: import random letters = [‘a’,’g’,’s’,’s’,’c’,’v’,’e’,’g’,’d’,’g’] random_letter = random.choice(letters) guesses_left = 5 while guesses_left > 0: guess = input("Your guess: ") if guess == random_letter: print ("You win!") break guesses_left -= 1 else: print ("You lose.") My question: Why am I able to type other types than strings? For example, if I ..

Read more

For some dumb reason, I can’t get my if..elif to print in python 3 but it somehow works in python 2. I’m not sure what I missed. This is my if, elif def encdec(userinput, machine, plaintext): if userinput == 1: print("———————————–") print("Encoded:") enc = machine.encrypt(plaintext) print(enc) elif userinput == 2: print("———————————–") print("Decoded:") dec = machine.decrypt(plaintext) ..

Read more

I have a list which could change of number of elements list = [‘sp’, ‘gb’, ‘fr’] And I have 3 dictionaries where i can find some information about each country. dic_old_price = {‘sp’:3355, ‘gb’: 3000, ‘fr’:3500} dic_new_price = {‘sp’:3005, ‘gb’: 2500, ‘fr’:3000} dic_discount = {‘sp’: 0.20, ‘gb’: 0.15, ‘fr’:0.20} Well, now I want make a ..

Read more

My question: is it possible to make a calendar by using tkcalendar that when I press the button on a specific date information from a textfile appears? The different textfiles: day0.txt: Today is 2020/11/26 Soccer day1.txt: Today is 2020/11/27 Basketball … day364.txt: Today is 2021/11/26 Run Code: from tkinter import * from tkcalendar import * ..

Read more