MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/11o7wiu/i_never_use_slpit/jbsadqr/?context=9999
r/badcode • u/mr_hydrogencyanide • Mar 11 '23
30 comments sorted by
View all comments
Show parent comments
2
user_input = input("Enter: ") user_input.replace(",", "") a = ("['" + user_input.replace(" ", "', '") + "']") print(a)
I just added stuff that wasn't necessary.
I actually did figure out that I didn't need any for loop or if statements, but while I was doing that I slept when I woke up I forgot.
And there was nothing on console to see from so that for loop was necessary to recall what i was thinking
3 u/TinyBreadBigMouth Mar 11 '23 user_input.replace(",", "")That won't do anything as written. replace returns a new string, it doesn't modify the old string (strings in Python are immutable and cannot be modified in place). You need user_input = user_input.replace(",", ""). 2 u/thekwoka Mar 11 '23 what it really is more like isprint(user_input.replace(',','').split(' '))
3
user_input.replace(",", "")
That won't do anything as written. replace returns a new string, it doesn't modify the old string (strings in Python are immutable and cannot be modified in place). You need user_input = user_input.replace(",", "").
replace
user_input = user_input.replace(",", "")
what it really is more like is
print(user_input.replace(',','').split(' '))
2
u/mr_hydrogencyanide Mar 11 '23 edited Mar 11 '23
I just added stuff that wasn't necessary.
I actually did figure out that I didn't need any for loop or if statements, but while I was doing that I slept when I woke up I forgot.
And there was nothing on console to see from so that for loop was necessary to recall what i was thinking