6 votes
365 views
in Technology by 🧝 Drifter (230 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()

1 Answer

0 votes
by 👑 Grand Master (2.43m points)
Ah yes, computer sphagetti.

Related questions

2 votes
2 answers 73 views
asked Apr 14 in Homework Help by Jacob sucks
6 votes
8 answers 339 views
5 votes
2 answers 151 views
asked Feb 19 in KS Tech Support by Naccim 🌟 Mystic (327k points)
12 votes
8 answers 466 views
asked May 8, 2025 in Other by GBPACKERSFAN10 🌠 Star Seer (859k points)
30 votes
7 answers 537 views
asked Apr 17, 2025 in KS Tech Support by kidzsearch 🧙 Wizard (620k points) [admin]
11 votes
7 answers 327 views
asked Apr 16, 2025 in Other by Hyude 🔥 Spellbinder (129k points) [mod]
10 votes
1 answer 149 views
asked Mar 9, 2025 in Serious Stuff by sky_on_pawz
13 votes
15 answers 838 views
asked Feb 27, 2025 in Mental Health by ⬧J⬧A⬧S⬧M⬧I⬧N 🪞 Light Weaver (85.8k points)
10 votes
1 answer 269 views
asked Feb 27, 2025 in Mental Health by ★~Academic_Success~★ 🌀 Sorcerer (32.5k points)
11 votes
1 answer 253 views
7 votes
3 answers 381 views
asked Oct 9, 2024 in Other by Moonycat
6 votes
7 answers 1.5k views
6 votes
1 answer 297 views
4 votes
2 answers 466 views
6 votes
4 answers 808 views
4 votes
1 answer 541 views
5 votes
2 answers 522 views
10 votes
1 answer 627 views
asked May 14, 2023 in Other by jenxst4rs 🔮 Warlock (72.4k points)
6 votes
1 answer 319 views
5 votes
1 answer 334 views
4 votes
2 answers 575 views
6 votes
3 answers 633 views
asked Jul 14, 2022 in Other by TomBoyFoxGrl ⚗️ Conjurer (17.8k points)
6 votes
1 answer 994 views
8 votes
1 answer 469 views
25 votes
1 answer 758 views
asked Jan 13, 2020 in Ask KidzSearch Staff by PUMPKIN 🌌 Galactic Overlord (2.66m points) [prez/mod]
14 votes
1 answer 415 views
asked Feb 15, 2017 in General News by that potato in the corner... in the shel
23 votes
4 answers 1.2k views
asked Sep 27, 2016 in Personal by rae 🔥 Spellbinder (114k points)
...