[Tutor] Help Passing Variables
dangulko at hotmail.com
Thu Oct 18 09:08:08 CEST 2012
Hi Python Tutor, I have a write a simple function named "SwapCaseAndCenter(a_string, width). The idea is to use the function swapcase and center so that when the userenters a string it centers it and swaps the case (e.g. upper to lower and vice versa). The function calls for passing in two variables "a_string, width" but I am still confused on this concept. In my code below I seem to be able to pass in the variable "a_string" and found out how to use the "center along with swapcase" functions. I am still unsure howto pass in the variable "width". In my code I have hard coded the centering but I am not sure if instead I use the variable width to determine the centering. Any suggestions, help or examples of how to do this is appreciated.
def SwapCaseAndCenter(a_string): while True:
a_string=raw_input("give me a word: (enter to quit): ")
elif not a_string:
print "you did not provide a word. goodbye"
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor