#π Homework is slowly killing me :((
39 messages Β· Page 1 of 1 (latest)
@heavy lion
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.
what error?
Can you share the error message in text please?
sorry lol i forgot
ok so name[index] getting the letter out of a name string
mhm
u r using input but then doing ("student") that isnt possible
!e
name = "Bob"
index = 1
print(name[index])
:white_check_mark: Your 3.12 eval job has completed with return code 0.
o
what is the value of name?
thanks :))
uhm im gonna be honest i dont known what that means we started python like a week ago
sorry lol im a little stupid
thats ok
Can you explain the first 3 lines of your script is and what is it supposed to be doing?
okay, the numname variable is meant to store the number of people takinmg the test, so it will only ask for that many names, the name one is just to store names of people and the *numname after it is meant to make the array store how ever many names it needs, same with the test score
I see
So you're supposed to append() the input into the name list
And repeat for the test score too
in line 2 you are creating an empty list name because numname = 0 but append is a better way to go
Do you know how to use .append() @heavy lion ?
nope , not at all
but i thought in input would chaneg numname to above 0
!e
basket = []
print("This basket is empty")
print(basket)
print("I'm gonna add milk into my basket")
print(basket.append("milk"))
print("There's milk in my basket")
print(basket)
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | This basket is empty
002 | []
003 | I'm gonna add milk into my basket
004 | None
005 | There's milk in my basket
006 | ['milk']
It won't
input() will prompt for the user to enter whatever value you ask the user to and will save it as a string back to the variable its assigned to (if there is one)
name = input("What is your name? ") # Assuming the user typed "Bob"
print(name) # This will display "Bob"
So put them together you get,
names.append(input("Enter student name: "))
But put that into a loop
You could move the name list assignment to after input number of students but go with append
cool
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.