[Tutor] Help Passing Variables
David Hutto
dwightdhutto at gmail.com
Thu Oct 18 10:09:06 CEST 2012
Algorithm it, and look at the instance below the function first where
variables are drawn in as raw input, and comments with # are just
comments, not part of the code:
def SwapCaseAndCenter(a_string, upper_or_lower = None):
#find if it's upper, and print
if upper_or_lower == "upper":
print a_string.center(center_num).upper()
#find if it's upper, and print
if upper_or_lower == "lower":
print a_string.center(center_num).lower()
#Instance of function SwapCaseAndCenter vars input
#define the string to be upper/lower cased and centered at a particular point
a_string = raw_input("Give me a word, or letter: ")
#define if it's upper or lower
upper_or_lower = raw_input("upper, or lower character(s): ")
#define where it should be centered with an int cast
center_num = int(raw_input("Where should number be centered?: "))
#call the function with the params, and look above to the function
SwapCaseAndCenter(a_string, upper_or_lower)
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
More information about the Tutor
mailing list