Random text in Python
📁 Advanced Python Topics, example, Beginner
How to make random text in Python? So that it displays only 1 variable out of two? For example, I have two variables with the following values:
import random role1 = "Peaceful resident" role2 = "Mafia" role = random.randint(role1, role2) print("You are - " + role) input() And I need only one variable to be displayed when outputting the text. Moreover, each time - different, sometimes role1, sometimes role2, then again role1.
I hope I explained it clearly. I am a beginner in Python and I ask you to answer in more detail.
No answers yet.
Log in to leave an answer
Blogs
Java in 2025: A Complete Guide for Beginners from Scratch
Kotlin for Machine Learning: Capabilities and Limitations in Practice
CQRS and Event Sourcing in Swift: Architecture for Complex Projects
Converting NSURL to NSString in Swift: A Complete Guide with Examples