Shuffling a Word

0 votes
How do we shuffle a word's letters randomly in python?

For example, the word "cat" might be changed into 'act', 'tac' or 'tca'.

How can I do this without using built-in functions?
Jan 30 in Python by ana1504.k
• 7,470 points
13 views

1 answer to this question.

0 votes
You can try the following:

import random
word = "cat"
shuffled = list(word)
random.shuffle(shuffled)
shuffled = ''.join(shuffled)
print shuffled
answered Jan 30 by SDeb
• 12,360 points

Related Questions In Python

0 votes
1 answer

How to print first character of each word in upper case of a string in Python

You can use split() using space as ...READ MORE

answered Jun 1, 2018 in Python by george
• 200 points
1,390 views
0 votes
1 answer

How to check plural & singular form of a word?

You can try with the inflect 0.2.4 ...READ MORE

answered Jan 3 in Python by anonymous
131 views
0 votes
1 answer

How to search for a word in a string in Python?

You can do it like this: txt = ...READ MORE

answered Apr 4 in Python by Kumar
23 views
0 votes
1 answer

how to check whether a string starts with a particular word?

For this, you can use the built-in ...READ MORE

answered 4 days ago in Python by Neel
• 1,610 points
10 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 132 views
0 votes
1 answer

Return a list inside a for loop while iterating over the elements of another list

The print() is getting called multiple times ...READ MORE

answered Sep 21, 2018 in Python by SDeb
• 12,360 points
42 views
0 votes
1 answer

Is there a string 'contains' in python?

In this case, you can use the ...READ MORE

answered Sep 25, 2018 in Python by SDeb
• 12,360 points
51 views