0

I'm new to python and trying to create a program to calculate grade. I've been stuck on below for over an hour now so any help appreciate.

assessment=[]    
weight=[]    
assign_number = int(input('How many assessment : '))    
for i in range(assign_number):    
   asses_name =input('Enter name of assessment: ')     
   assessment.append(asses_name)   
   asses_value = int(input(print('How many marks is the',assessment[i],'worth : ')))   
   weight.append(asses_value)

the problem is the asses_value keep returning none?example is below

How many assessment : 3
Enter name of assessment: test
How many marks is the test worth :
None

Any hint is appreciated, thanks everyone

2 Answers 2

1

The print() function in Python always returns None. So you need to remove it from this line:

asses_value = int(input(print('How many marks is the',assessment[i],'worth : ')))

Simply passing a string to the input function does what you need:

asses_value = int(input('How many marks is the ' + assessment[i] + ' worth : '))

Note that you can only pass a single string to input() though, which is why I have used the string concatenation operator + rather than passing three comma-separated strings.

As pointed out in the comments, an improvement to the above would be to use string formatting:

asses_value = int(input('How many marks is the {} worth : '.format(assessment[i])))
Sign up to request clarification or add additional context in comments.

Comments

0

Hope! This code will help you out

assessment=[]    
weight=[]    
assign_number = int(input('How many assessment : '))    
for i in range(assign_number):    
   asses_name =input('Enter name of assessment: ')     
   assessment.append(asses_name)   
   asses_value = int(input('How many marks is the ' +assessment[i]+' worth : '))
   weight.append(asses_value)

Update: You tried to print the the value while taking the input that's why all the error occur

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.