Skip to content
I Need Help...
Profile icon
Dominicl645

print threeNum
b. check if index 0 is < 5
i. if threeNum[0] < 5, replace index 0 with the string: “small”
ii. else, replace index 0 with a string: “large”
c. print threeNum

i have to do this, but when i put the proper signs in, it throws a error at me. Any ideas for what i can do to fix it?

You are viewing a single comment. View All
Answered by SUHASTADIPARTH1 [earned 5 cycles]
View Answer
Profile icon
Coder100

You forgot that you are comparing to an integer!
Your list type is a string
You are comparing an int

so it will never be true!
Change your code to:

if threeNum[0] == "5": threeNum[0] = "small" print(threeNum) elif threeNum[0] == "5": threeNum[0] = "big" print(threeNum)

or:

if int(threeNum[0]) == 5: threeNum[0] = "small" print(threeNum) elif int(threeNum[0]) == 5: threeNum[0] = "big" print(threeNum)
Profile icon
Dominicl645

hey, thanks for the help.

@Coder100

Profile icon
Coder100
Profile icon
Dominicl645

how have you been during COVID?

@Coder100

Profile icon
Coder100
Profile icon
Dominicl645

thats good.

@Coder100

Profile icon
Coder100

thanks! You?

@dominicl645

Profile icon
Dominicl645

im ok. thx for asking.

@Coder100