human
Find the Sum of the series 1 , 2 , 3 , 6 , 9 , 18 , 27 , 54 , ... till N terms | Function to find the sum of series.
Flag to find the multiplicating factor . . i . e , by 2 or 3 / 2.
First term.
If flag is true , multiply by 2.
If flag is false , multiply by 3 / 2.
Update the previous element to nextElement.
Print the sum.
Driver Code"
How can the above be solved in Python?

Give me a code to find the Sum of the series 1 , 2 , 3 , 6 , 9 , 18 , 27 , 54 ,?
assistant
#Here is code to find the Sum of the series 1 , 2 , 3 , 6 , 9 , 18 , 27 , 54 , .
 def printSeriesSum ( N ) :
	sum = 0 ;
	a = 1 ;
	cnt = 0 ;
	flag = True ;
	sum += a ;
	while ( cnt < N ) :
		nextElement = None ;
		if ( flag ) :
			nextElement = a * 2 ;
			sum += nextElement ;
			flag = not flag ;
		else :
			nextElement = a * ( 3 / 2 ) ;
			sum += nextElement ;
			flag = not flag ;
		a = nextElement ;
		cnt += 1
	print ( sum ) ;
if __name__ == " _ _ main _ _ " :
	N = 8 ;
	printSeriesSum ( N ) ;