By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,967 Members | 2,124 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,967 IT Pros & Developers. It's quick & easy.

how can I delet "None" in code output

shahram555
P: 4
Expand|Select|Wrap|Line Numbers
  1. >>class class1:
  2.      name='civil'
  3.      def printname(self,name):
  4.          print self.name
  5.          print name
  6. >>you=class1()
  7. >>you.mark=100
  8. >>print you.printname('shahram'),you.mark
  9.  
  10.   civil
  11.   shahram
  12.   None 100
Aug 26 '14 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 619
Expand|Select|Wrap|Line Numbers
  1. print you.printname('shahram'),you.mark
prints the return from printname which is None. Try the following code
Expand|Select|Wrap|Line Numbers
  1. class class1:
  2.      name='civil'
  3.      def printname(self,name):
  4.          print self.name
  5.          print name
  6.          print self.mark
  7.          return "returned from printname"
  8.  
  9. you=class1()
  10. you.mark=100
  11. print you.printname('shahram')
So you have to return something you want to print, or eliminate the print statement. You might want to look at this tutorial on functions which includes return statements.
Aug 26 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.