-2

I need help with a pprint function. I'm trying to make a program that records student ID numbers, their names, age, class rank, and gpa. I need to use a pprint() function to print the dictionary out. Here's my code so far.

student=dict()
student['ID']= raw_input ("What is your student ID number?")
student['name']= raw_input ("What is your name?") 
student['age']= raw_input ("How old are you?") 
student['rank']= raw_input ("What is your class rank?")
student['gpa']= raw_input ("What is your current GPA?")

What do I need to do? I've tried multiple variations of code, but nothings working. Thanks!

Jack
  • 191
  • 1
  • 2
  • 7
  • 2
    When claiming that your previous attempts do not work, it helps to share those previous attempts so we can point out where you went wrong. – chepner Nov 01 '13 at 18:30

3 Answers3

3

Import pprint function from pprint module and pass student to it:

from pprint import pprint
pprint(student)
Ashwini Chaudhary
  • 244,495
  • 58
  • 464
  • 504
1

You're storing the info, but you haven't printed anything at all.

http://docs.python.org/2/library/pprint.html

import pprint
pp = pprint.PrettyPrinter()
pp.pprint(student)
John Spong
  • 1,361
  • 7
  • 8
0

You need to import pprint and after you have gotten all the input print it out using pprint.pprint(student)

Andy
  • 49,085
  • 60
  • 166
  • 233