Function list_benefits prints a set of strings. What i assume you want it to do is return a list.
So:
return ['More organized code', 'More readable code' , 'Easier code reuse' 'Allowing programmers to share and connect code together']
User Profile
Collapse
-
Code:dim = int(input("Enter the size of the diamond: ")) area = int(input('Enter the numer of times to be printed: ')) def diamond(size, times): for j in range(times): for i in range(size): print (" "*(size-i) + "* " * i +" "*(size-i))*times for i in range(size+1): print (" "*(i) + "* "*(size-i)
Leave a comment:
-
-
-
try to compress it.
If you are using windows, right click the folder and send to -> Compressed (Zipped) folder.Leave a comment:
-
I would say start with Geany (Small and easy) or CodeBlocks (More features) unless you really want and/or need eclipse.
CentOS is Redhat based right? try and look for a eclipse install howto for redhat and try that.Leave a comment:
-
it means that if line does not contain anything it continues to the next iteration of the loopLeave a comment:
-
Well to start of I think this is best solved with regular expressions.
Code:>>> import re >>> s = "text45677text82" >>> rxp = re.compile("[A-Za-z]") >>> re.split(rxp,s) ['', '', '', '', '45677', '', '', '', '82'] >>>
Leave a comment:
-
I don't know if its enough to add
Code:#coding: UTF-8
Code:unicode(string) #or when you create the string: a = u"string"
Leave a comment:
-
Because the program is stuck in an infinite loop and never creates the screen or rectangle.Leave a comment:
-
well it seems as if it can not find numpy. Try reinstalling it and make sure it all ends up in the correct place.Leave a comment:
-
I'm not sure what's going on there but I think you should look in to the join attribute of strings as well as slicing.
Code:>>> l=[0,'f',0,1,1,1,0,'a',8] >>> " ".join([str(i) for i in l[:3]]) '0 f 0'
Slicing works as follows sequence[x:y:z] where;
sequence = any list tuple or string
...Leave a comment:
-
Guessing wildly here but I think what you are after is best accomplished with a dictionary.
But I'm not sure what you are on about with "assign each individual piece of the string to a corresponding variable.". Or exactly how the data looks like. Or how you want to access it later.
But still a dictionary is a great tool.
Code:>>> dd = {} >>> dd["add"] = lambda x, y: x+y
Leave a comment:
-
In python 2.7 print (first_name, last_name) print the representation of the truple (first_name, last_name). If you remove the parentheses it will print the strings first_name and last_name.
In python 2.x print is a statment and does not use parentheses.
In python 3.x print is a function and requires parentheses.Leave a comment:
-
Code:def acronymPhrase(phrase): return "".join([x[0] for x in phrase.split()]) if __name__ == "__main__": print (acronymPhrase(raw_input("Give a phrase: ")))
Code:Give a phrase: I Am A Little Bee IAALB >>>
Leave a comment:
-
Your problem is a missing : after else and a missing ' in the last print.
Code:else: print ('x is the largest')
Leave a comment:
-
As far as I can tell you don't actually have an issue.
And if you have an issue I can not reproduce it. Since I believe it does not have anything to do with Python. But rather think its an issue with width limitation for characters in whatever you use to view the output. Because in Python it's correctly stored as one line when I use readlines.Leave a comment:
-
Not sure what exactly that action does since I do not program in C so here are what I guess it does:
Code:a = [] for i in range(1,4): a.append(i) print a >>> [1, 2, 3]
Leave a comment:
-
-
the variable a is in the test2 namespace.
try
Code:test2.a.test1()
Code:import test2 # to: from test2 import *
Leave a comment:
No activity results to display
Show More
Leave a comment: