0

I'm doing a python 3 tutorial and i'm trying to figure out where in my output these parentheses are coming from.

students = int (input())
total = dict()
for i in range(0,students):
  tokens = input().split()
  name = tokens[0]
  total[name] = float(tokens[1]) + float(tokens[2]) + float(tokens[3])

student = input(())
print ("{0:.2f}".format(total[student] / 3))

Expected Output

56.00

My Output

()56.00

2 Answers 2

2

replace this:

student = input(())

with:

student = input()

This is what happening :

 >>> student = input(())
()
Sign up to request clarification or add additional context in comments.

Comments

0

In student = input(()) you are passing an empty tuple as the prompt argument to the input function. Normally, you pass input a prompt string, however input (and raw_input in Python 2) will happily accept any object for the prompt and convert it to a string, just like print does. If no prompt is supplied then no prompt gets printed. (I suspect that input simply passes the prompt to print).

So your unexpected () is simply that empty tuple, converted to a string.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.