Question: Write a program which substitutes a random letter within a string with a random vowel. The program then prints the new string. Given the following
Write a program which substitutes a random letter within a string with a random vowel. The program then prints the new string.
Given the following initialization statement for the variable original_string:
original_string = "specialist"
the program will produce the following output:
The new string is: seecialist
Note:
- Do not import the random module. This has been done for you as part of the CodeRunner setup for this question.
- Do not include the initialization statement for the variable original_string. This will be provided for you for each test case.
- You should first use the random.randrange() function to obtain a random position within the original_string. Then use the random.randrange() function to obtain a random position within the vowel string.
For example:
| Test | Result |
|---|---|
random.seed(32) original_string = "specialist" | The new string is: seecialist |
random.seed(322) original_string = "television" | The new string is: televieion |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
