Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- tests_count = int(input())
- tests = [input() for _ in range(tests_count)]
- for test in tests:
- print(reverse_words_position(test))
- def reverse_words_position(string):
- reversed_words = []
- if string == "":
- return string
- start_pos = 0
- end_pos = len(string)
- in_word = False
- for index, i in enumerate(string):
- if not in_word and i != ".":
- start_pos = index
- in_word = True
- elif i == ".":
- reversed_words.insert(0, string[start_pos:index])
- in_word = False
- elif index == len(string) - 1:
- reversed_words.insert(0, string[start_pos:index+1])
- in_word = False
- return ".".join(reversed_words)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement