## Remove i'th character

0 likes • Nov 19, 2022
Python

## More Python Posts

`# Python program for Plotting Fibonacci # spiral fractal using Turtle import turtle import math   def fiboPlot(n):     a = 0    b = 1    square_a = a     square_b = b       # Setting the colour of the plotting pen to blue     x.pencolor("blue")       # Drawing the first square     x.forward(b * factor)     x.left(90)     x.forward(b * factor)     x.left(90)     x.forward(b * factor)     x.left(90)     x.forward(b * factor)       # Proceeding in the Fibonacci Series     temp = square_b     square_b = square_b + square_a     square_a = temp           # Drawing the rest of the squares     for i in range(1, n):         x.backward(square_a * factor)         x.right(90)         x.forward(square_b * factor)         x.left(90)         x.forward(square_b * factor)         x.left(90)         x.forward(square_b * factor)           # Proceeding in the Fibonacci Series         temp = square_b         square_b = square_b + square_a         square_a = temp       # Bringing the pen to starting point of the spiral plot     x.penup()     x.setposition(factor, 0)     x.seth(0)     x.pendown()       # Setting the colour of the plotting pen to red     x.pencolor("red")       # Fibonacci Spiral Plot     x.left(90)     for i in range(n):         print(b)         fdwd = math.pi * b * factor / 2        fdwd /= 90        for j in range(90):             x.forward(fdwd)             x.left(1)         temp = a         a = b         b = temp + b     # Here 'factor' signifies the multiplicative  # factor which expands or shrinks the scale # of the plot by a certain factor. factor = 1  # Taking Input for the number of  # Iterations our Algorithm will run n = int(input('Enter the number of iterations (must be > 1): '))   # Plotting the Fibonacci Spiral Fractal  # and printing the corresponding Fibonacci Number if n > 0:     print("Fibonacci series for", n, "elements :")     x = turtle.Turtle()     x.speed(100)     fiboPlot(n)     turtle.done() else:     print("Number of iterations must be > 0")`
`import copybegining = [False,False,False,False,False,None,True,True,True,True,True]#False = black True = whiteits = [0]def swap(layout, step):    layoutCopy = copy.deepcopy(layout)    layoutCopy[(step[0]+step[1])], layoutCopy[step[1]] = layoutCopy[step[1]], layoutCopy[(step[0]+step[1])]    return layoutCopydef isSolved(layout):    for i in range(len(layout)):        if(layout[i] == False):            return (i >= (len(layout)/2))def recurse(layout, its, steps = []):    if isSolved(layout):        its[0] += 1        print(layout,list(x[0] for x in steps))        return    step = None    for i in range(len(layout)):        if(layout[i] == None):            if(i >= 1): #If the empty space could have something to the left                if(layout[i - 1] == False):                    step = [-1,i]                    recurse(swap(layout,step), its, (steps+[step]))                if(i > 1): #If the empty space could have something 2 to the left                    if(layout[i - 2] == False):                        step = [-2,i]                        recurse(swap(layout,step), its, (steps+[step]))            if(i < (len(layout)-1)): #If the empty space could have something to the right                if(layout[i + 1] == True):                    step = [1,i]                    recurse(swap(layout,step), its, (steps+[step]))                if(i < (len(layout)-2)): #If the empty space could have something to the right                    if(layout[i + 2] == True):                        step = [2,i]                        recurse(swap(layout,step), its, (steps+[step]))    its[0] += 1    #return Nonerecurse(begining,its,[])print(its[0])`
```def calculate_values():    value1 = 10    value2 = 20    return value1, value2
result1, result2 = calculate_values()print("Result 1:", result1)print("Result 2:", result2)```
`""" Rock Paper Scissors----------------------------------------"""import randomimport osimport reos.system('cls' if os.name=='nt' else 'clear')while (1 < 2):    print "\n"    print "Rock, Paper, Scissors - Shoot!"    userChoice = raw_input("Choose your weapon [R]ock], [P]aper, or [S]cissors: ")    if not re.match("[SsRrPp]", userChoice):        print "Please choose a letter:"        print "[R]ock, [S]cissors or [P]aper."        continue    // Echo the user's choice    print "You chose: " + userChoice    choices = ['R', 'P', 'S']    opponenetChoice = random.choice(choices)    print "I chose: " + opponenetChoice    if opponenetChoice == str.upper(userChoice):        print "Tie! "    #if opponenetChoice == str("R") and str.upper(userChoice) == "P"    elif opponenetChoice == 'R' and userChoice.upper() == 'S':              print "Scissors beats rock, I win! "        continue    elif opponenetChoice == 'S' and userChoice.upper() == 'P':              print "Scissors beats paper! I win! "        continue    elif opponenetChoice == 'P' and userChoice.upper() == 'R':              print "Paper beat rock, I win! "        continue    else:               print "You win!"`
```def max_n(lst, n = 1):  return sorted(lst, reverse = True)[:n]
max_n([1, 2, 3]) # [3]max_n([1, 2, 3], 2) # [3, 2]```
```def print_x_pattern(size):    i,j = 0,size - 1
while j >= 0 and i < size:
initial_spaces = ' '*min(i,j)        middle_spaces = ' '*(abs(i - j) - 1)        final_spaces = ' '*(size - 1 - max(i,j))
if j == i:            print(initial_spaces + '*' + final_spaces)        else:            print(initial_spaces + '*' + middle_spaces + '*' + final_spaces)
i += 1        j -= 1
print_x_pattern(7)```