Randomly shuffle input strings

Asked 2 years ago, Updated 2 years ago, 30 views

import random

list = []

word=int(input('Enter:')))

list.append(word)

random.shuffle(list)

print(list)

I'm trying to do this, but it's not mixed What's the problem?

python

2022-09-20 22:14

2 Answers

import random

l = list(input('Enter:')))

random.shuffle(l)

print(l)

If you don't have to change the values in the list to integer, you can do it in the same way as above.


2022-09-20 22:14

import random

list = []

word=str(input('Enter:'))
for i in range(0, len(s)):
    list.append(i)

random.shuffle(list)

print(list, "output")

This is how it works. I don't know if the result of your question is correct. (If you change the number of digits in the input, you need to add some code back to the part that handles the input value)


2022-09-20 22:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.