Invalid Literal For int() With Base.. Error

Hello! I got stuck in this error! I can’t figure it out what exactly wrong with this code. Could you explain me, please?

Could you explain what you are trying to do? The immediate problem is that the grade string is empty.

At a larger scope, it looks like you expect the input('text here') calls to return that text. That’s not going to work, input uses the text as a prompt and returns whatever you type in response. I guess you actually want to use those texts as your sample text, so instead you could use e.g. for grades:

grades = '81, 77, 92, 88'.split(', ')

Though it’d make more sense to skip the split and directly use a list:

grades = [81, 77, 92, 88]

Firstly I am so thankful for your response @airtower-luna
What am I trying to do: I am just a beginner in Python and try to figure it out how the codes work. Actually I’m doing an Online Course from a website and that code was written as a solution for a quiz from Scripting with Raw Input Subject. But as I tried to write it and to see how it works, I was just surprised because of that “Error”.

I just tried what you told me that just using directly a list but it didn’t help me. I couldn’t see still the output like in the solution below:

Well, if you want help you’ll have to describe the actual problem: what are you doing (in this case: code!), what is happening, what do you expect to happen instead? That screenshot covers only the last part.

Sorry I have tried to put two more photos but I couldn’t because I am just a new member, I am not allowed to put more photos. But I copied and pasted below what the problem is:

Quiz: Generate Messages

Imagine you’re a teacher who needs to send a message to each of your students reminding them of their missing assignments and grade in the class. You have each of their names, number of missing assignments, and grades on a spreadsheet and just have to insert them into placeholders in this message you came up with:

Hi [insert student name] ,

This is a reminder that you have [insert number of missing assignments] assignments left to submit before you can graduate. Your current grade is [insert current grade] and can increase to [insert potential grade] if you submit all assignments before the due date.

You can just copy and paste this message to each student and manually insert the appropriate values each time, but instead you’re going to write a program that does this for you.

Write a script that does the following:

  1. Ask for user input 3 times. Once for a list of names, once for a list of missing assignment counts, and once for a list of grades. Use this input to create lists for names , assignments , and grades .
  2. Use a loop to print the message for each student with the correct values. The potential grade is simply the current grade added to two times the number of missing assignments.

Template code for your script:

names =  # get and process input for a list of names
assignments =  # get and process input for a list of the number of assignments
grades =  # get and process input for a list of grades

# message string to be used for each student
# HINT: use .format() with this string in your for loop
message = "Hi {},\n\nThis is a reminder that you have {} assignments left to \
submit before you can graduate. You're current grade is {} and can increase \
to {} if you submit all assignments before the due date.\n\n"

# write a for loop that iterates through each set of names, assignments, and grades to print each student's message

What @airtower-luna and others are looking for is the code that you’ve currently written. Copy it from your terminal / editor / browser, and paste it as a reply here using the “preformatted text” icon. We don’t want screenshots, we want text.

Based on your template code, the program needs to prompt for input, and you, as the user, must manually enter the data. As @airtower-luna points out, you need to use input correctly, e.g.:

grades = input('enter grades')

You then would type in the necessary string, i.e. 81,77,92,88.


Right now I got it! It was my foolishness that I thought the code gets the inputs automatically… Thank you so much both @fire-eggs and @airtower-luna

1 Like

Don’t beat yourself up about this! Not foolishness - ignorance. Ignorance can be corrected, you are learning and we all had to learn this stuff some time!