Issue
Here is part of my code:
i = int(input("length of speech: " ))
b = 0
while b < i:
print(random.choice(uppercase)+ " ", end = "")
b += 1
Solution
You definitely have the right idea if you want to do this with a loop.
uppercase = [...] # your list goes here
while len(uppercase) > 0:
i = random.randint(0, len(uppercase)) # Pick a random index in the list
print(uppercase[i]) # Print out the corresponding element
del uppercase[i] # Delete the element from the list and start again
Answered By - gavinmccabe
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.