wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
disp('result') | disp('result') | Correct. | MATLAB |
<hr></hr> | <hr> | Self-closing. | HTML |
if (val = 54) {{}} | if (val == 54) {{}} | Use ==. | Java |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
def handle():
print('hello') | def handle():
print('hello') | Indent function body. | Python |
data[52] | if (data.indices.contains(52)) data[52] | Check index. | Kotlin |
jwt.sign({{id:31}}, 'key'); | jwt.sign({{id:31}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
var x int | var x int | Correct. | Go |
b == '70' | b === 70 | Use strict equality. | JavaScript |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
list.forEach(function(result) {{ console.log(result); }}) | list.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
int num = 'info'; | String num = 'info'; | Type mismatch. | Dart |
for (num in arr) | for (num of arr) | for...in iterates keys. | JavaScript |
fn process() -> i32 {{ 48 }} | fn process() -> i32 {{ 48 }} | Correct. | Rust |
switch(item){{ case 48: break; }} | switch(item){{ case 48: break; default: break; }} | Add default case. | Java |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
os.sqrt(30) | import os
os.sqrt(30) | Import module first. | Python |
[77, 32, 66 | [77, 32, 66] | Close bracket. | Python |
if (c = 16) | if (c == 16) | Use ==. | Scala |
print 'message' | print 'message'; | Add semicolon. | Perl |
[x*x for x in list if x > 80] | [x*x for x in list if x > 80] | Correct list comprehension. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
x := 95 | x := 95 | Correct. | Go |
os.sqrt(87) | import os
os.sqrt(87) | Import module first. | Python |
function bar() {{
return
{{key:'test'}}
}} | function bar() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
println('data') | println("data") | Double quotes. | Scala |
<entry name='value'/> | <entry name="value"/> | Double quotes. | XML |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
if (bar = 76) | if (bar == 76) | Use ==. | Scala |
status: value
name: world, | status: value
name: world | Remove comma. | YAML |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
$arr[14] | if ($arr.Count -gt 14) {{ $arr[14] }} | Check bounds. | PowerShell |
if foo = 73 then
print('hello')
end | if foo == 73 then
print('hello')
end | Use ==. | Lua |
let x: Int = 'world' | let x: String = 'world' | Fix type. | Swift |
function foo(num:string){{return num;}} foo(47); | function foo(num:string){{return num;}} foo('message'); | Pass correct type. | TypeScript |
arr[74] | if arr.indices.contains(74) {{ arr[74] }} | Check index. | Swift |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
def process(x):
return x + 1 | def process(x):
return x + 1 | Correct. | Python |
def foo
puts 'hello'
end | def foo
puts 'hello'
end | Correct. | Ruby |
h1 {{ font-size:6px color:#333; }} | h1 {{ font-size:6px; color:#333; }} | Add semicolon. | CSS |
fn foo() -> i32 {{ 20 }} | fn foo() -> i32 {{ 20 }} | Correct. | Rust |
[x*x for x in data if x > 23] | [x*x for x in data if x > 23] | Correct list comprehension. | Python |
print 'hello' | print('hello') | print needs parentheses. | Python |
val data = 12; data = 12 | var data = 12; data = 12 | Use var for reassignment. | Scala |
for i=1,27 do print(i) end | for i=1,27 do print(i) end | Correct. | Lua |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
[88, 51, 14 | [88, 51, 14] | Close bracket. | Python |
let text1 = String::from("message"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let text = String::from("output"); let ref=&text; text.push_str("!"); | let mut text = String::from("output"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
{{'value':'value'}} | {{"value":"value"}} | Use double quotes. | JSON |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let a = 97; let a = 4; | let a = 97; a = 4; | Duplicate declaration. | JavaScript |
if (data = 80) | if (data == 80) | Use ==. | C++ |
{{"status":"result" "value":86}} | {{"status":"result", "value":86}} | Add comma. | JSON |
yield num | yield num | Correct yield. | Python |
index = result | index = 'result' | Quote strings. | Python |
{{"title":"message",}} | {{"title":"message"}} | Remove trailing comma. | JSON |
if (index = 15) {{}} | if (index === 15) {{}} | Use === for equality. | JavaScript |
else
print('info') | else:
print('info') | Colon after else. | Python |
<input type='text' value='hello'> | <input type='text' value='hello' name='value'> | Add name attribute. | HTML |
<entry><desc>output</desc><age>38</age></entry | <entry><desc>output</desc><age>38</age></entry> | Add closing >. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
print('world') | print('world') | Correct. | R |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
DELETE FROM products WHERE email=65 | DELETE FROM products WHERE email=65; | Add semicolon. | SQL |
my @arr = (43,6,23); | my @arr = (43,6,23); | Correct. | Perl |
while temp > 25
temp -= 1 | while temp > 25:
temp -= 1 | Colon missing after while. | Python |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
if ($foo = 77) | if ($foo == 77) | Use ==. | Perl |
INSERT INTO users VALUES ('world',9) | INSERT INTO users (age, role) VALUES ('world',9); | Specify columns. | SQL |
let data = 52; data += 1; | let mut data = 52; data += 1; | Need mut to modify. | Rust |
let mut c=71; let ref1=&mut c; let r2=&mut c; | let mut c=71; {{ let ref1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
let x: number = 'message'; | let x: string = 'message'; | Fix type. | TypeScript |
'output' + 7 | 'output' + str(7) | Can't add int to string. | Python |
if (index = 41) {} | if (index == 41) {} | Use ==. | Dart |
process | process() | Add parentheses. | Swift |
$items[68] = 5; | if (isset($items[68])) $items[68] = 5; | Check existence. | PHP |
<br></br> | <br> | Self-closing. | HTML |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
let v=vec![82,77,88]; let head=&v[0]; v.push(76); | let mut v=vec![82,77,88]; let head=v[0]; v.push(76); | Copy instead of reference. | Rust |
items[58] | if (items.indices.contains(58)) items[58] | Check index. | Kotlin |
let val = 27; | let val = 27; | Correct. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
if temp = 23 | if temp == 23 | Use ==. | MATLAB |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
[83, 29, 88 | [83, 29, 88] | Close bracket. | Ruby |
let a: number | null = null; a.toFixed(72); | let a: number | null = null; if(a!==null) a.toFixed(72); | Null check. | TypeScript |
object Item {{ def main(args: Array[String]) = println("info") }} | object Item {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
for (num in list) | for (num of list) | for...in iterates keys. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.