Re: [Tutor] Help Passing Variables

2012-10-29 Thread Prasad, Ramit
David Hutto wrote: > #A little more complex in terms of params: > > def SwapCaseAndCenter(*kwargs): > > if upper_or_lower == "upper": > print a_string.center(center_num).upper() > > if upper_or_lower == "lower": > print a_string.center(center_num).lower()

Re: [Tutor] Help Passing Variables

2012-10-26 Thread David Hutto
#Apologies, this is the actual code: def SwapCaseAndCenter(a_string, upper_or_lower = None, center_num = None): if upper_or_lower == "upper": print a_string.center(center_num).upper() if upper_or_lower == "lower": print a_string.center(center_num)

Re: [Tutor] Help Passing Variables

2012-10-26 Thread David Hutto
#A little more complex in terms of params: def SwapCaseAndCenter(*kwargs): if upper_or_lower == "upper": print a_string.center(center_num).upper() if upper_or_lower == "lower": print a_string.center(center_num).lower() a_string = raw_input("Give m

Re: [Tutor] Help Passing Variables

2012-10-26 Thread David Hutto
#This is the actual code: def SwapCaseAndCenter(a_string, upper_or_lower = None): if upper_or_lower == "upper": print a_string.center(center_num).upper() if upper_or_lower == "lower": print a_string.center(center_num).lower() a_string = raw_input(

Re: [Tutor] Help Passing Variables

2012-10-26 Thread David Hutto
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":

Re: [Tutor] Help Passing Variables

2012-10-19 Thread Dave Angel
y not after the things they follow? There is a long-standing convention in this forum, and many others, and why let Microsoft ruin it for all of us? >> Date: Thu, 18 Oct 2012 04:44:55 -0400 >> Subject: Re: [Tutor] Help Passing Variables >> From: dwightdhu...@gmail.com >> To

Re: [Tutor] Help Passing Variables

2012-10-19 Thread Daniel Gulko
Thanks David. This has been helpful in understanding a bit more on how parameters are passed through. > Date: Thu, 18 Oct 2012 04:44:55 -0400 > Subject: Re: [Tutor] Help Passing Variables > From: dwightdhu...@gmail.com > To: dangu...@hotmail.com > CC: tutor@python.org >

Re: [Tutor] Help Passing Variables

2012-10-18 Thread Dave Angel
On 10/18/2012 03:08 AM, Daniel Gulko wrote: > > > > Hi Python Tutor, I have a write a simple function named > "SwapCaseAndCenter(a_string, width). So why did you define it with only one formal parameter? > The idea is to use the function swapcase and center so that when the > userenters a stri

Re: [Tutor] Help Passing Variables

2012-10-18 Thread Alan Gauld
On 18/10/12 08:08, Daniel Gulko wrote: The function calls for passing in two variables "a_string, width" but I am still confused on this concept. You just provide the list of input parameters when you define the function: >>> def add(x,y): ... return x+y ... >>> add(4,5) 9 I define add to t

[Tutor] Help Passing Variables

2012-10-18 Thread Daniel Gulko
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