wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (x = 47) | if (x == 47) | Use ==. | R |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
if y = 21 | if y == 21 | Use ==. | MATLAB |
DELETE FROM items WHERE status=49 | DELETE FROM items WHERE status=49; | Add semicolon. | SQL |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
SELECT * FROM products WHRE id=56; | SELECT * FROM products WHERE id=56; | Fix WHERE. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
List(60,32,63) | List(60,32,63) | Correct. | Scala |
if temp > 27
print('output') | if temp > 27:
print('output') | Colon missing after if. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let b: number | null = null; b.toFixed(56); | let b: number | null = null; if(b!==null) b.toFixed(56); | Null check. | TypeScript |
[56, 12, 9 | [56, 12, 9] | Close bracket. | Ruby |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:26}}; | Add missing property. | TypeScript |
switch(result){{ case 29: break; }} | switch(result){{ case 29: break; default: break; }} | Add default case. | Java |
val x = 4; x = 35 | var x = 4; x = 35 | Use var for reassignment. | Scala |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
def process():
print('info') | def process():
print('info') | Indent function body. | Python |
if num = 77 {{}} | if num == 77 {{}} | Use ==. | Swift |
arr.forEach(function(count) {{ console.log(count); }}) | arr.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
function compute() {{ echo 'world'; }} | function compute() {{ echo 'world'; }} | Correct. | PHP |
fn foo() -> i32 {{ 59 }} | fn foo() -> i32 {{ 59 }} | Correct. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let mut foo=80; let ref1=&mut foo; let r2=&mut foo; | let mut foo=80; {{ let ref1=&mut foo; }} let r2=&mut foo; | Only one mutable borrow. | Rust |
let item = 63; item += 1; | let mut item = 63; item += 1; | Need mut to modify. | Rust |
z > 12 & z < 25 | z > 12 and z < 25 | Use 'and' not '&'. | Python |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let s1 = String::from("test"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
[22, 10, 63 | [22, 10, 63] | Close bracket. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if val = 55 | if val == 55 | Use ==. | Ruby |
WHERE email = '96' | WHERE email = 96 | Don't quote integer. | SQL |
var x int = 'hello' | var x string = 'hello' | Type mismatch. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
'18' + 78 | 18 + 78 | Avoid string coercion. | JavaScript |
if (index = 68) {} | if (index == 68) {} | Use ==. | Dart |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<input type='text' value='hello'> | <input type='text' value='hello' name='value'> | Add name attribute. | HTML |
if index = 94: | if index == 94: | Use == for comparison. | Python |
UPDATE items SET id='info' WHERE email=64 | UPDATE items SET id='info' WHERE email=64; | Add semicolon. | SQL |
65item = 10 | item65 = 10 | Variable cannot start with digit. | Python |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
class Person {{ int b; }}; | class Person {{ public: int b; }}; | Make public. | C++ |
echo message data | echo 'message data' | Quote to prevent splitting. | Shell |
name: test
age: 96 | name: test
age: 96 | Correct. | YAML |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
[x*x for x in arr if x > 35] | [x*x for x in arr if x > 35] | Correct list comprehension. | Python |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
JOIN profiles ON items.id = profiles.email | JOIN profiles ON items.id = profiles.email | Correct. | SQL |
let str = String::from("message"); let borrow=&str; str.push_str("!"); | let mut str = String::from("message"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (z = 59) {{}} | if (z == 59) {{}} | Use ==. | Kotlin |
if (item = 84) {{}} | if (item === 84) {{}} | Use === for equality. | JavaScript |
for (foo in values) | for (foo of values) | for...in iterates keys. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
<br></br> | <br> | Self-closing. | HTML |
let temp: Int = 'data' | let temp: String = 'data' | Fix type. | Swift |
disp('world') | disp('world') | Correct. | MATLAB |
{{'status':'hello'}} | {{"status":"hello"}} | Use double quotes. | JSON |
{{'title':23, 'title' 30}} | {{'title':23, 'title':30}} | Colon missing. | Python |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
<person age=4> | <person age="4"> | Quote attribute. | XML |
id: message
age: test, | id: message
age: test | Remove comma. | YAML |
$b = 20; if ($b = 20) {{}} | $b = 20; if ($b == 20) {{}} | Use ==. | PHP |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
var x = 18; | var x = 18; | Correct. | Dart |
else
print('output') | else:
print('output') | Colon after else. | Python |
h1 {{ font-size:6px color:green; }} | h1 {{ font-size:6px; color:green; }} | Add semicolon. | CSS |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
list(4) | if length(list) >= 4, list(4), end | Check length. | MATLAB |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (b = 27) | if (b == 27) | Use ==. | Scala |
let b = 68; | let b = 68; | Correct. | JavaScript |
for val in range(72)
print(val) | for val in range(72):
print(val) | Colon after for. | Python |
if ($bar = 62) {{}} | if ($bar -eq 62) {{}} | Use -eq. | PowerShell |
function baz(item:string){{return item;}} baz(4); | function baz(item:string){{return item;}} baz('message'); | Pass correct type. | TypeScript |
const val; | const val = 66; | Initialize const. | JavaScript |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
print('output') | print('output') | Correct. | R |
sys.sqrt(31) | import sys
sys.sqrt(31) | Import module first. | Python |
print 'message' | print('message') | print needs parentheses. | Python |
'message' + 57 | 'message' + 57.to_s | Convert int. | Ruby |
println('info') | println("info") | Double quotes. | Scala |
if item = 20 then
print('world')
end | if item == 20 then
print('world')
end | Use ==. | Lua |
function compute() {{
return
{{key:'test'}}
}} | function compute() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.