+4 votes
72 views
in Technology by (210 points)

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()




Your answer

Your name to display (optional DO NOT USE REAL NAME):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in the future, please log in or register.



Related questions

0 votes
2 answers 34 views
+2 votes
5 answers 162 views
+1 vote
1 answer 72 views
+3 votes
2 answers 82 views
+6 votes
1 answer 60 views
+4 votes
1 answer 53 views
+3 votes
1 answer 85 views
+1 vote
2 answers 121 views
+3 votes
3 answers 169 views
asked Jul 14, 2022 in Other by TomBoyFoxGrl (13.6k points)
+3 votes
1 answer 430 views
+5 votes
1 answer 130 views
+10 votes
1 answer 214 views
asked Feb 15, 2017 in General News by that potato in the corner... in the shel
+13 votes
4 answers 423 views
asked Sep 27, 2016 in Personal by rae (110k points)

Recent Badges

Notable Question
Asked question received 50 views
- CarlyTheSwede -
Popular Question
Asked question received 100 views
- ~GrlPWR4Eva~ -
Notable Question
Asked question received 50 views
- Coolgir1 -
Famous Question
Asked question received 500 views
- hilolo -
Notable Question
Asked question received 50 views
- HorseLover -
...