Issue
How can I make it that when the user enters input its on the same line as the print statement
like for example for the code snippet below. The output becomes:
Enter grade for course 1: A
Enter credits for course 1: 4
For now this is what I get:
Enter grade for course 1:
A
Enter credits for course 1:
4
Here is the code snippet
for i in range(1,coursenumber+1):
print("Enter grade for course ", i,":", end =""),
grade=str(input())
print("Enter credits for course", i,":", end =" ")
credit=int(input())
totalgpa+=translate(credit,grade)
totalcredit+=credit
Solution
You can write the question inside the input function like
for i in range(1,coursenumber+1):
grade=input(f"Enter grade for course {i}:")
credit=input(f"Enter credits for course {i}:")
totalgpa+=translate(credit,grade)
totalcredit+=credit
Then the input prompt appears right next to the question
Answered By - Kazuya Hatta
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.