#๐ code
78 messages ยท Page 1 of 1 (latest)
@plain wadi
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.
Hey @plain wadi!
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
def read2Dictionary():
dict={}
file=open("student.txt","r")
data= file.readlines()
file.close()
for line in data:
line=line.split(",")
ID=int(line[0])
Name=line[1]
grades=float(line[2:])
dict[ID]=+dict[ID]
dict.values=list[Name,grades]
return dict
You can't assign to a dict's values like that
you should also never use dict as a variable name
Did you have any questions you wanted to ask about this code?
i wanna know whats wrong
bc i asked chatgpt and his method isnt one i kow
know
so i wanna know whats wrong
this is chatgpt code?
dict.values is a function fyi
You're nearly there, but just a few things need to change
don't use dict as the variable name for dict
why are you using += there?
what da flip
already mentioned ๐
christ the whole party is here
ah right thanks
fr
no one is judging
no1 is judging, we just giving advice
I'm trying to get a sense of what you understand so I can better explain
What do you think this is doing?
dict.keys()=dict[ID]
you eventually need to end up with a format like this
we never assign to keys() or values()
the format is ID is the key, and then the value is a list
well how do i do it
let's start with that. We need to create a list that will hold the name and the grades
so i add a list=[]
do you know how to create a list and add things to it?
under dict={}
don't use list as a variable name
why
I strongly recommend renaming dict as well
my uni does it all the time man
they are builtins
because list and dict are python datatypes. They already have a meaning
u dont want to override builtins
name your variables based on what they contain
not what they are
what is it a list of?
what is it a dict of?
students = {} would be a much better name here
and lst=[]
student_info = []
um
nvm man
don't be lazy and do it right, even in practice
ok so we have a list named student_info
what needs to go into that list?
@plain wadi still there?
yea i dont need help thank u
If that's all you can close this thread then 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.