#๐ someone help me
73 messages ยท Page 1 of 1 (latest)
@fickle mango
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Print this and print listsd. See what's in them.
Same bug as the previous one to my eye.
yep
@fickle mango okay so
a function
returns something
right
also i m seeing that since its a reference and not a new value so i cant assign a new value to it?
even when it returns nothing, it returns None, which is still "somethinf"
Have you printed them yet?
Also print(this) after the insert call.
now what happens to listsd after you say defkne it as text.split @fickle mango
i got u i want to make listd = this anyhow
so in next for loop it searches in list
instead of listd
basically changing the listd
i could not get what u saying
listsd = ...
its useless
the default python functions normally always use this formst
u can modify the data itself or create a new version of the data which is modified right away
sorted(list) and list.sort()
are great examples
so with sorted we are returning a sorted version of the list
as the name implies
with list.sort we are modifying the existing list
does this make sense? @fickle mango
gimme 2 mins
yeah so u saying basically in case value in place changes then function if didnt return anything still original value get affected
but i want to smh make both of them equal
so it searches for word in 'this'///
theres more to it id say but lets keep this close to a college course and so let you figure that out 5 years later
so .insert returns None
we know that
but it doesnt affect the original data
so
im gonna blow ur mind here
no way
wait
it affects i thought
instead of value = list.insert
lets do
list.insert
with assigning the output to a value
why now its not doing inplace and still returning None
sentence = "ADJECTIVE is NOUN and VERB is NOUN too."
for word in sentence.split():
print(word)
if word in ("ADJECTIVE", "NOUN", "VERB"):
sentence = sentence.replace(word, input(f"Enter a {word}: "))
print(sentence)```
take this as an example
''.join(...) returns a value but you haven't assigned the output to anything, it doesn't actually change the listsd variable
can u give a list which returns and which dont /
I'm not sure which ones you know yet but it's a simple fix, just do my_variable = ''.join(...) instead if you want to keep that
i tried this trick of joining and splitting again to reassign it again
what's the point of joining the string back before adding the word? just do whaty I did in the example
sub it into the list directly
this is easy
to assign it a variable
which i cant directly
coz it changes value of list directly
isnt it possible to do it with join and split though like i did?
tyvm
like literally i was stuck for 12 hours
its working now
!close
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.