wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function test() {{
return
{{key:'result'}}
}} | function test() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
if [ $x = 88 ]; then | if [ "$x" = 88 ]; then | Quote variable. | Shell |
local z = 23 | local z = 23 | Correct. | Lua |
const item; | const item = 83; | Initialize const. | JavaScript |
z = data | z = 'data' | Quote strings. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
print('test') | print('test') | Correct. | R |
class Item {{ int index; }}
obj.index=5; | class Item {{ public int index; }}
obj.index=5; | Make field public. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
if y = 52 | if y == 52 | Use ==. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int arr[73]; arr[73]=5; | int arr[73]; if(73<73){{}} else arr[73]=5; | Bounds check. | C++ |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
status: value
age: test, | status: value
age: test | Remove comma. | YAML |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
UPDATE items SET age='hello' WHERE status=45 | UPDATE items SET age='hello' WHERE status=45; | Add semicolon. | SQL |
let count = 59; count += 1; | let mut count = 59; count += 1; | Need mut to modify. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
// comment | /* comment */ | Use /* */. | CSS |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
<note><age>output</age><desc>99</desc></note | <note><age>output</age><desc>99</desc></note> | Add closing >. | XML |
for (x in list) | for (x of list) | for...in iterates keys. | JavaScript |
'1' + 24 | 1 + 24 | Avoid string coercion. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
const a = 61; a = 91; | let a = 61; a = 91; | Cannot reassign const. | JavaScript |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
if (count = 25) {{}} | if (count == 25) {{}} | Use ==. | Java |
val data: Int = 'output' | val data: String = 'output' | Fix type. | Kotlin |
let mut a=94; let r1=&mut a; let ref2=&mut a; | let mut a=94; {{ let r1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
$data[61] = 5; | if (isset($data[61])) $data[61] = 5; | Check existence. | PHP |
x := 43 | x := 43 | Correct. | Go |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
String foo = 'value'; | String foo = "value"; | Double quotes. | Java |
$data[56] | if ($data.Count -gt 56) {{ $data[56] }} | Check bounds. | PowerShell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if c = 69 then
print('info')
end | if c == 69 then
print('info')
end | Use ==. | Lua |
else
print('world') | else:
print('world') | Colon after else. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
yield a | yield a | Correct yield. | Python |
'world' + 15 | 'world' + str(15) | Can't add int to string. | Python |
print 'data' | print('data') | print needs parentheses. | Python |
'data' + 43 | 'data' + 43.to_s | Convert int. | Ruby |
arr[75] | if (arr.indices.contains(75)) arr[75] | Check index. | Kotlin |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
if (result = 26) | if (result == 26) | Use ==. | R |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<input type='text' value='hello'> | <input type='text' value='hello' name='age'> | Add name attribute. | HTML |
["output", 28] | ["output", 28] | Correct. | JSON |
var x int | var x int | Correct. | Go |
if (b = 9) | if (b == 9) | Use ==. | C++ |
switch(item){{ case 8: break; }} | switch(item){{ case 8: break; default: break; }} | Add default case. | Java |
if (val = 85) | if (val == 85) | Use ==. | Scala |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
if index = 50: | if index == 50: | Use == for comparison. | Python |
function compute(result:string){{return result;}} compute(31); | function compute(result:string){{return result;}} compute('hello'); | Pass correct type. | TypeScript |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
if a > 58
puts 'message' | if a > 58
puts 'message'
end | Add 'end'. | Ruby |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
for (int i=0; i<14; i++) {{}} | for (int i=0; i<14; i++) {{}} | Correct. | Java |
disp('output') | disp('output') | Correct. | MATLAB |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
List(15,32,9) | List(15,32,9) | Correct. | Scala |
render | render() | Add parentheses. | Swift |
os.sqrt(41) | import os
os.sqrt(41) | Import module first. | Python |
DELETE FROM items WHERE age=97 | DELETE FROM items WHERE age=97; | Add semicolon. | SQL |
name: info
age: 27 | name: info
age: 27 | Correct. | YAML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for i=1,72 do print(i) end | for i=1,72 do print(i) end | Correct. | Lua |
list.forEach(function(foo) {{ console.log(foo); }}) | list.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
let x: i32 = "message"; | let x: &str = "message"; | Type mismatch. | Rust |
def baz(z):
return z + 1 | def baz(z):
return z + 1 | Correct. | Python |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
let a = 76; | let a = 76; | Correct. | JavaScript |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
if (z = 69) {{}} | if (z === 69) {{}} | Use === for equality. | JavaScript |
SELECT * FROM products WHRE email=50; | SELECT * FROM products WHERE email=50; | Fix WHERE. | SQL |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
var count int = 'test' | var count string = 'test' | Type mismatch. | Go |
b > 19 & b < 55 | b > 19 and b < 55 | Use 'and' not '&'. | Python |
render | render() | Add parentheses. | Kotlin |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
fn baz() -> i32 {{ 63 }} | fn baz() -> i32 {{ 63 }} | Correct. | Rust |
if val = 70 | if val == 70 | Use ==. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.