I'm having trouble trying to put a random.randint into my list and making it work so far I have this:
strings = [str(chr(random.randint(65, 90))) % x for x in range(0, int(uppercase) 1)]
for string in strings:
print(string)
I can get it to work without random.randint with just adding text but I can not get it to work for random.randint
Also I want to see if I can turn the list into a single sentence "useful for my purpose"
CodePudding user response:
You might try the following:
strings = []
for x in range(0, int(uppercase) 1):
strings.append(str(chr(random.randint(65, 90))))
For creating a single sentence:
result = ""
for element in strings:
result = str(element)
print(result)
CodePudding user response:
First of all you should start your range from 1 to avoid zero division error you can use this example instead:
strings = [str(random.randint(65, 90) % x) for x in range(1, int(uppercase))]
for string in strings:
print(string)
The output is like this:
0
0
2
0
In this case uppercase is "5"