233k views
2 votes
What's wrong with this python code i don't know what's wrong with both of them

What's wrong with this python code i don't know what's wrong with both of them-example-1
What's wrong with this python code i don't know what's wrong with both of them-example-1
What's wrong with this python code i don't know what's wrong with both of them-example-2

1 Answer

6 votes

Answer:

Keep it in the format

first one:

def swapping_stars():

line_str = ""

for line in range(6, 8):

for char in range(0, 6):

if line % 2 == char % 2:

line_str = line_str + "*"

else:

line_str = line_str + "-"

print(str(line_str))

swapping_stars()

second one:

if you want it to go:

23456

def print_numbers(list):

for i in range(1, len(list)):

print(str(list[i]))

num_list = [1, 2, 3, 4, 5, 6]

print_numbers(num_list)

if you want it to go

123456

def print_numbers(list):

doneONE = False

for i in range(1, len(list)):

if not doneONE:

print(str(list[i] - 1))

doneONE = True

print(str(list[i]))

num_list = [1, 2, 3, 4, 5, 6]

print_numbers(num_list)

Step-by-step explanation:

User Chinloong
by
3.7k points