Given a String, the task is to write a Python program to convert its characters to uppercase randomly.
Input : test_str = 'geeksforgeeks' Output : GeeksfORgeeks Explanation : Random elements are converted to Upper case characters. Input : test_str = 'gfg' Output : GFg Explanation : Random elements are converted to Upper case characters.
In this, we perform the task of choosing random characters to upper case using choice() at each character. The upper() and lower() perform task of uppercasing and lowercasing characters respectively.
The original string is : geeksforgeeks Random Uppercased Strings : gEEkSFoRgEeKS
In this, we imply choice() over all the characters of lowercase and uppercase Strings joined (using zip()), using map().
The original string is : geeksforgeeks Random Uppercased Strings : geEkSFORgEEKS
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. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course