Python
Programming Exercises, Gently Explained
108
for i in range(1000):
random.shuffle(chars)
assert getTitleCase(''.join(chars)) == ''.join(chars).title()
The code in the for loop generates random strings and checks that your getTitleCase()
function returns the same string that Python’s built-in title() string method does. This allows us
to quickly generate 1,000 test cases for your solution.
Try to write a solution based on the information in this description. If you still
have trouble
solving this exercise,
read the Solution Design and Special Cases and Gotchas sections for
additional hints.
Prerequisite concepts: strings, for loops, range(), len(), upper(), isalpha(), lower()
Dostları ilə paylaş: