Last active
July 16, 2019 17:48
-
-
Save Himan10/387666477967124fbe727e3cb9b184e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import string | |
| import time | |
| # pattern = r'[\W_ ]' - regex pattern | |
| def convert(data): | |
| new_data = '' | |
| for i in range(0, len(data)): | |
| if data[i] in string.ascii_letters: | |
| new_data = new_data + data[i] | |
| print(len(new_data)) | |
| return new_data | |
| def print_series(data): | |
| print(', '.join(data[0: i+1] for i in range(0, len(data), 1))) | |
| def print_series2(data): | |
| print(', '.join(data[0:i] + data[i] for i in range(0, len(data)))) | |
| def recursive(data, n, m): # m is the length of data | |
| if n == m: | |
| return data | |
| else: | |
| print(data[0:n], end = ', ') | |
| return recursive(data, n+1, m) | |
| if __name__ == "__main__": | |
| w = convert("She-Hulk Smash") | |
| print_series(w) | |
| print() | |
| print_series2(w) | |
| print() | |
| print(recursive(w, 1, len(w))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment