+ 3

Ptyhon delvopment fasten your seatbelt

I don’t see what’s wrong with the code I put fasten my seatbelt three times I don’t see what’s wrong Here is my code fasten your seatbelt fasten your seatbelt fasten your seatbelt

28th Mar 2025, 2:06 PM
Christian Francis
Christian Francis - avatar
5 Answers
+ 4
Yes
28th Mar 2025, 2:36 PM
Kiwi
Kiwi - avatar
+ 4
There are few mistakes I found. 1. The required output is "Fasten your seat belt" and print it 3 times. Not "fasten your seatbelt". Case and space have to match exactly. 2. Where is the print()? 3. The most important one. This practice is about for loop. Your solution with correct syntax can pass the test though, it is not intended to be solving like this. How would you do if the practice asks you to print it 1000 times? Would you copy the same instruction 1000 times? Follow the comments given in the exercise and try the for loop approach.
28th Mar 2025, 2:49 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
Hehe
28th Mar 2025, 2:36 PM
Kiwi
Kiwi - avatar
+ 1
Oh i see
28th Mar 2025, 3:05 PM
Christian Francis
Christian Francis - avatar
0
Christian Francis, without the print() function there's no use of this code. Nothing will be displayed on the screen. It is best to use a for loop for executing programs like this. But, if you're a beginner and wish to avoid loop statements, here's another way to do this: print('fasten your seatbelt\n' *3) Output: fasten your seatbelt fasten your seatbelt fasten your seatbelt Explanation: String multiplication has been used here. The original string gets repeated three times for *3 (i.e. n times for *n). [Note:- Make sure you do not multiply with 0 or a negative integer because that will return an empty string (no output) and a float will raise a TypeError. ] When you use the newline character (\n) in a string, it tells the python interpreter to break and start from a new line. So, each repeation appears on a new line.
30th Mar 2025, 9:30 AM
Ushasi Bhattacharya