Song of Pi

 1 def main():

 2     pi = '31415926535897932384626433833' # 预先给出需要比较的值

 3     t = int(raw_input()) 

 4     for _ in xrange(t):

 5         song = raw_input().strip().split(' ') # 消除尾部的换行,按照空格分割

 6         is_pi_song = True

 7         for i, song_word in enumerate(song): # 逐位对比

 8             if int(pi[i]) != len(song_word):

 9                 is_pi_song = False

10                 break

11         if is_pi_song:

12             print "It's a pi song."

13         else:

14             print "It's not a pi song."

15 

16 main()

 

你可能感兴趣的:(on)