#πŸ”’ Homework is slowly killing me :((

39 messages Β· Page 1 of 1 (latest)

heavy lion
#

i put an image of my code, i dont understand what the error means, im trying to ask how manym people took an exam but its gibing me and error, can someone pls help me

vague stagBOT
#

@heavy lion

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.

heavy lion
pure cradle
#

Can you share the error message in text please?

heavy lion
#

sorry lol i forgot

pure cradle
# heavy lion

ok so name[index] getting the letter out of a name string

heavy lion
#

mhm

oblique niche
#

u r using input but then doing ("student") that isnt possible

pure cradle
#

!e

name = "Bob"
index = 1
print(name[index])
vague stagBOT
heavy lion
#

uhm im gonna be honest i dont known what that means we started python like a week ago

#

sorry lol im a little stupid

pure cradle
#

thats ok

pure cradle
heavy lion
#

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

pure cradle
#

I see

#

So you're supposed to append() the input into the name list

#

And repeat for the test score too

devout summit
#

in line 2 you are creating an empty list name because numname = 0 but append is a better way to go

pure cradle
#

Do you know how to use .append() @heavy lion ?

heavy lion
#

nope , not at all

heavy lion
pure cradle
#

!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)
vague stagBOT
pure cradle
#

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

devout summit
#

You could move the name list assignment to after input number of students but go with append

heavy lion
#

yeah, okay thankds :))

#

ill try iut now

#

thanks :))

pure cradle
#

cool

vague stagBOT
#
Python help channel closed

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.