Given the string, the task is to generate the same string using the random combination of special character, numbers, and alphabets.
Input : GFG Output :n4W mK7 k1x q;;, !g . . . . . GF, GFf GFp GFG Target matched after 167 iterations
Prerequisite : Generating random Id’s in Python
string.ascii_uppercase are some of the common string constants present in the string module in Python, which are used here as dictionary. All these string constants are combined with other special characters like ‘ ., !?;:’ and are stored in a variable.
Approach : Simply run two loops and use random function provided by python. It will show all the possible combinations that can be provided by the random function and same thing will be done by the decrypt loop. At the end, it will show the same text as you have inserted when prompted to enter. It will match each random string with the given string. If both index matches then fix that index and iterate for the remaining.
Below is the implementation :
FyFJ .:YZ aubo . . . g56G gk6R g7Se gT o gD d gXek g0ek g ek . . gUek giek geek Target matched after 168 iterations
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Generating random Id's in Python
- Generating Random id's using UUID in Python
- Generating Random Integers in Pandas Dataframe
- Generating random number list in Python
- Random sampling in numpy | random() function
- random.random() function in Python
- Python | Count the elements in a list until an element is a Tuple
- Python | Remove and print every third from list until it becomes empty
- Python | Visualize graphs generated in NetworkX using Matplotlib
- Generating hash id's using uuid3() and uuid5() in Python
- Generating Word Cloud in Python
- Generating Word Cloud in Python | Set 2
- Generating subarrays using recursion
- Generating Strong Password using Python
- Generating Basic Discrete Time Signals
- Generating all possible Subsequences using Recursion
- Reading and Generating QR codes in Python using QRtools
- Python | Generate random string of given length
- Python Program to Generate Random binary string
- Python - Random Replacement of Word in String
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.