'Arrange a string if it's odd
I have a string, I want to be able to move all the digits that appear odd numbers of times in the string to move to the front of the string IN ascending order. The rest of the string remains intact
This is what I have tried till now:
from collections import Counter
def getOddOccurrence(myString):
count = Counter(myString)
for letter in myString:
if count[letter] % 2 != 0:
return letter
myString = "sfsdfsdfs"
print(getOddOccurrence(myString))
Solution 1:[1]
Try this:
import os
# traverse whole directory
for root, dirs, files in os.walk(r'C:\Users\file_path_here'):
# select file name
for each_file in files:
# check the extension of files
if each_file.endswith('.kml'):
# print whole path of files
print(os.path.join(root, file))
kml_file = open(each_file, "r")
content = kml_file.read()
file.close()
with open('newfile.kml', 'w') as f:
f.write(content)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharman |
