0
Can anyone tell me what is the error in this program I want to produce letter F with this program.
shape = "@" no_of_lines = 8 current_line = 1 while current_line <= no_of_lines : if current_line == 1 or 4: print(shape * 10) else: print(shape * 2) current_line += 1
7 ответов
+ 5
(1, 4) is a tuple. That's a datatype containing more than one value.
x in (1, 4) checks if the value of x is in that tuple, in other words: if x is either 1 or 4.
You wrote x==1 or 4.
This means: Either x equals 1, or 4 is true.
Get that? You're just checking if 4 is true, you aren't checking, if it equals x.
You could have written x==1 or x==4 instead - that way you'd be checking for both.
x in (1, 4) is shorter though.
+ 3
Change line 5 to this:
if current_line in (1, 4):
(Do you understand what went wrong?)
+ 3
Thanks HonFu bro for your detailed explanation
And thanks kiibo Ghayal for your link and explanation
And thanks Rithea Sreng
Now I understand my error.
THANKS ALL
+ 2
Sorry brother, I am a beginner so I don't know what does in(1,4) refer to or what does it mean ,pls tell me.