jeudi 7 février 2019

Creating Random Strings in Python

import random

string1 = "Fred"
string2 = "Jones"
int1 = 4
int2 = 8
randomInt = random.randint(1, 100)
GloriousListOfFun = [string1, string2, int1, int2, randomInt]
RandomFromGloriousListOfFun = random.choice(GloriousListOfFun)

x=0
while x<1: 
    line1 = "Hi I am {} from Albion".format(RandomFromGloriousListOfFun)
    print(line1)

I know this is 99.9% useless but right now this would return something like: "Hi I am 9 from Albion" "Hi I am 9 from Albion" "Hi I am 9 from Albion" etc... Does anyone know how I could make it repeat itself like this but with a random variable every time? Thank you.




Aucun commentaire:

Enregistrer un commentaire