w3resource

Python: Create all possible strings by using a, e, i, o, u

Python Basic - 1: Exercise-2 with Solution

Write a Python program that creates all possible strings using the letters 'a', 'e', 'i', 'o', and 'I'. Ensure that each character is used only once.

Visual Presentation:

Python: Create all possible strings by using a, e, i, o, u

Sample Solution:

Python Code :

# Import the 'random' module to shuffle elements in a list randomly.
import random

# Create a list of characters containing vowels.
char_list = ['a', 'e', 'i', 'o', 'u']

# Shuffle the elements in the 'char_list' randomly.
random.shuffle(char_list)

# Print the shuffled list of characters as a string.
print(''.join(char_list))

Sample Output:

iauoe

Explanation:

The above code imports the "random" module, creates a list of vowels (char_list), shuffles the elements of the list randomly using "random.shuffle", and then prints the shuffled list as a string using 'join'. The result is a randomized sequence of vowels.

Flowchart:

Flowchart: Python - Create all possible strings by using a, e, i, o, u

Python Code Editor :

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python function that takes a sequence of numbers and determines if all the numbers are different from each other.
Next: Write a Python program to remove and print every third number from a list of numbers until the list becomes empty.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.