Print pi to a number of decimal places
问题 One of the challenges on w3resources is to print pi to 'n' decimal places. Here is my code: from math import pi fraser = str(pi) length_of_pi = [] number_of_places = raw_input("Enter the number of decimal places you want to see: ") for number_of_places in fraser: length_of_pi.append(str(number_of_places)) print "".join(length_of_pi) For whatever reason, it automatically prints pi without taking into account of any inputs. Any help would be great :) 回答1: Why not just format using number_of