Selecting random student code

IB Year 1 HL Computer Science
Forum rules
Please be careful about sharing personal information. Never use any identifiable information.
Post Reply
User avatar
Posts: 9
Joined: 17 Sep 2018, 10:14

Selecting random student code

Post by minseok123 » 16 Oct 2018, 22:19

Code: Select all

import random
import os

students_in_classes = [
    ["Jake", "Kim", "Lee"],
    ["Pol", "Laa","Deng"],
    ["Sam", "Pen", "Wom"],
    ["Ree", "Asen", "Rom"],
    ["Kim", "Alex", "Kris"]

def random_student ():

def clear_screen():
    os.system("cls" if == "nt" else "clear")

def show_classes ():
    index = 1
    for classes in students_in_classes:
        print("{}.".format(index), classes)
        index += 1


class_number = input("What is the number of the class of which you're teaching? ")
new_class = students_in_classes[int(class_number) - 1]

print("Your class:")

x = input("Press ENTER to randomly select a student")
if x == x:
How do I make it so that I can new_class -= the value returned when the function random_student is called?
1 x

User avatar
Mr. MacKenty
Site Admin
Posts: 88
Joined: 28 Apr 2018, 17:06
Answers: 3

Re: Selecting random student code

Post by Mr. MacKenty » 17 Oct 2018, 16:00

I am confused.

What exactly are you trying to do here? Why do you need to decrement:

Code: Select all

new_class = students_in_classes[int(class_number) - 1]
0 x

Post Reply