#๐Ÿ”’ someone help me

73 messages ยท Page 1 of 1 (latest)

fickle mango
fervent sunBOT
#

@fickle mango

Python help channel opened

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.

timber yoke
#

@fickle mango r u ok hahahahah

#

isnt this like ur 4th ticket within 20min

fickle mango
#

i gave up

#

i tried more than 14 hours :osb

lime lion
#

Print this and print listsd. See what's in them.

lime lion
timber yoke
#

@fickle mango okay so

#

a function

#

returns something

#

right

fickle mango
timber yoke
#

even when it returns nothing, it returns None, which is still "somethinf"

lime lion
#

Have you printed them yet?

fickle mango
lime lion
#

Also print(this) after the insert call.

timber yoke
#

now what happens to listsd after you say defkne it as text.split @fickle mango

fickle mango
#

so in next for loop it searches in list

#

instead of listd

#

basically changing the listd

fickle mango
timber yoke
fickle mango
#

its useless

timber yoke
#

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

fickle mango
fickle mango
#

but i want to smh make both of them equal

#

so it searches for word in 'this'///

timber yoke
#

so .insert returns None

#

we know that

#

but it doesnt affect the original data

#

so

#

im gonna blow ur mind here

fickle mango
#

wait

#

it affects i thought

timber yoke
#

instead of value = list.insert

#

lets do

#

list.insert

#

with assigning the output to a value

fickle mango
#

?

fickle mango
cerulean cradle
#
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

fickle mango
cerulean cradle
#

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

fickle mango
cerulean cradle
#

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

fickle mango
#

which i cant directly

#

coz it changes value of list directly

fickle mango
fickle mango
#

like literally i was stuck for 12 hours

#

its working now

#

!close

fervent sunBOT
#
Python help channel closed with !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.