Hello, I'm currently working on a project in the Python programming language.
Before I even got started on the actual project, I've already run into multiple problem.
During the grouping process, which the user needs to separate with commas, I remove spaces before the groups get appended to the string. However, when attempting to remove characters that are not in the valid string, (including spaces) do not seem to get removed.
I already have an idea why, (the .replace() method is not stored in any variable, only called) but do not have any clue how to implement this in my code. Please help.
valid = "abcdefghijklmnopqrstuvwxyz"
validategroups = []
validgroups = []
print("Unscrambler\nPress Enter...")
input()
while True:
going = 0
oldgoing = 0
groups = input("Enter Letter Groups: ").lower()
for x in range(len(groups)):
if groups[x] not in valid: groups[x].replace(groups[x], "")
print(groups)
input()
for x in range(len(groups)):
if groups[going] == ",":
validgroups.append(groups[oldgoing:going])
oldgoing = going
going += 1
print(validgroups)
input()
for group in validgroups:
for x in range(len(group)):
if "," in group[x]: group[x].replace(group[x], "")
ignored = []
print(validgroups)
input()