You seem to want to randomly select to display A
or B
. You can do this with the pre-installed random
module. random.choice
takes in a list and randomly returns one element from that list, which is the desired behavior.
import random
A = f"{name} {''.join(word2)} {inhabitants} inhabitants on an area of {surface}"
B = f"Che sale a"
text.insert(tk.END, random.choice([A, B]))
If you would like to use a more secure version of random.choice
, you can do so with the pre-installed secrets
module
import secrets
A = f"{name} {''.join(word2)} {inhabitants} inhabitants on an area of {surface}"
B = f"Che sale a"
text.insert(tk.END, secrets.choice([A, B]))