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, 2019 in Python by ana1504.k
• 7,910 points
795 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, 2019 by SDeb
• 13,300 points

Related Questions In Python

+1 vote
2 answers

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

class Solution:     def firstAlphabet(self, s):             self.s=s              k=''              k=k+s[0]              for i in range(len(s)):                     if ...READ MORE

answered Oct 28, 2020 in Python by Anurag
11,709 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, 2019 in Python by anonymous
3,993 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 5, 2019 in Python by Kumar
509 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 Jul 17, 2019 in Python by Neel
• 3,020 points
547 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,023 views
0 votes
1 answer
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 22, 2018 in Python by SDeb
• 13,300 points
4,652 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
• 13,300 points
504 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP