Last active
February 26, 2020 16:49
-
-
Save yaraxxx/9dca276ef603a6e51e5aac01b6f5733d to your computer and use it in GitHub Desktop.
Comma Saperated Values
This file contains 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
2 | |
some#important#data | |
gulf$open|programming%contest |
This file contains 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
def cal(): | |
line = input() | |
counter = 0 | |
for i in range(len(line)): | |
if(line[i] == '#' or line[i] == '$' or line[i] == '#' or line[i] == '%' or line[i] == '|'): | |
line = line.replace(line[i],',',1) | |
counter+=1 | |
return line , counter | |
def main(): | |
t = int(input()) | |
for case in range(t): | |
line , counter = cal() | |
print(line+','+str(counter+1)) # I added one to count to count the last word | |
if __name__=="__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment