I'm still new to python. Please help me. I'm trying to get an output with calling function in a single line only but the output that is called from the function gets print first leaving the print stated as a None. What should I do? Thanks for the help in advance.
My code:
def getGrade(mark):
if mark>=80:
print("A")
elif mark>=60 and mark<=79:
print("B")
elif mark>=40 and mark<=59:
print("C")
elif mark>0 and mark<=39:
print("F")
else:
print("Error")
user={}
for x in range(4):
a=input("Please enter your name: ")
b=int(input("Please enter your marks: "))
user[a.title()]=b
print(f"Hi {a}!Your Grade is {getGrade(b)}")
print(user)
The output I got:
Please enter your name: izz
Please enter your marks: 99
A
Hi izz!Your Grade is None
Please enter your name: mark
Please enter your marks: 65
B
Hi mark!Your Grade is None
Please enter your name: Kevin
Please enter your marks: 33
F
Hi kevin!Your Grade is None
Please enter your name: felly
Please enter your marks: 55
C
Hi felly!Your Grade is None
{'Izz': 99, 'Mark': 65, 'Kevin': 33, 'Felly': 55}
This is how I suppose to print out the output: Example of output (from 1 student): Hi Adam. Your grade is B.