Why is this wrong | Sololearn: Learn to code for FREE!
11th Jun 2024, 12:37 AM
Ahmed Fouad Eid El-Dmrdash
Ahmed Fouad Eid El-Dmrdash - avatar
8 Answers
+ 7
There are two errors in your code. 1. Indentation of line 2 is wrong; 2. "If" is not a valid keyword.
11th Jun 2024, 1:26 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 6
Hint: Python is case sensitive.
11th Jun 2024, 4:00 AM
Keith
Keith - avatar
+ 6
Ahmed Fouad Eid El-Dmrdash , additional to the suggestions from per bratthammar: # if we just wanted to skip *one* number we can use: for X in range(1,21): if X != 13: print(X) # if we wanted to skip *several numbers*, we can use: skip = [13, 15, 17] for X in range(1,21): if X not in skip: print(X)
11th Jun 2024, 3:24 PM
Lothar
Lothar - avatar
+ 3
# Hi Ahmed Fouad Eid El-Dmrdash, # In your case, it's better to use 'continue' instead of 'pass'. # If you want to skip multiple values in a range before printing them: rng = range(1, 18) skip = {5, 7, 8, 9, 11, 12, 13} # Convert the range to a set and subtract the 'skip' set, then sort and # print each value on a new line. print(*sorted(set(rng) - skip), sep='\n')
11th Jun 2024, 8:23 AM
Per Bratthammar
Per Bratthammar - avatar
+ 2
Nikky faith Web If you want to ask a question, please start your own thread by going to Create -> DISCUSS and clicking on the green plus sign.
12th Jun 2024, 8:46 PM
Keith
Keith - avatar
0
A range isn't an integer
11th Jun 2024, 7:02 PM
Jonathan Dodge
Jonathan Dodge - avatar
12th Jun 2024, 9:12 AM
Manos The Cuber
Manos The Cuber - avatar
0
How can I create calculator using HTML
12th Jun 2024, 8:42 PM
Nikky faith Web
Nikky faith Web - avatar