wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
// comment | /* comment */ | Use /* */. | CSS |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
if data = 1 | if data == 1 | Use ==. | Go |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
var x int | var x int | Correct. | Go |
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 |
val data: Int = 'result' | val data: String = 'result' | Fix type. | Kotlin |
while data > 82
data -= 1 | while data > 82:
data -= 1 | Colon missing after while. | Python |
function compute(): void {{ return 29; }} | function compute(): number {{ return 29; }} | Return type mismatch. | TypeScript |
List(46,53,63) | List(46,53,63) | Correct. | Scala |
object Product {{ def main(args: Array[String]) = println("value") }} | object Product {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
<entry><name>test</name><desc>89</desc></entry | <entry><name>test</name><desc>89</desc></entry> | Add closing >. | XML |
[43, 16, 100 | [43, 16, 100] | Close bracket. | Ruby |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
data.forEach(function(z) {{ console.log(z); }}) | data.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
fn baz() -> i32 {{ 49 }} | fn baz() -> i32 {{ 49 }} | Correct. | Rust |
foo = test | foo = 'test' | Quote strings. | Python |
<input type='text' value='message'> | <input type='text' value='message' name='id'> | Add name attribute. | HTML |
<entry name='value'/> | <entry name="value"/> | Double quotes. | XML |
assert z > 40 | assert z > 40 | Correct. | Python |
foo | foo() | Add parentheses. | Swift |
["world", 95] | ["world", 95] | Correct. | JSON |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
def test
puts 'output'
end | def test
puts 'output'
end | Correct. | Ruby |
if (z = 43) | if (z == 43) | Use ==. | Scala |
'55' + 82 | 55 + 82 | Avoid string coercion. | JavaScript |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
render | render() | Add parentheses. | Kotlin |
DELETE FROM orders WHERE id=11 | DELETE FROM orders WHERE id=11; | Add semicolon. | SQL |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
'output' + 44 | 'output' + str(44) | Can't add int to string. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if a = 82 | if a == 82 | Use ==. | MATLAB |
let b = 'hello' | let b = "hello" | Double quotes. | Swift |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let index = 96; let index = 3; | let index = 96; index = 3; | Duplicate declaration. | JavaScript |
if count = 23: | if count == 23: | Use == for comparison. | Python |
let c: number = 'world'; | let c: string = 'world'; | Fix type. | TypeScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let b: i32 = "value"; | let b: &str = "value"; | Type mismatch. | Rust |
if [ $bar = 78 ]; then | if [ "$bar" = 78 ]; then | Quote variable. | Shell |
const person:Person = {{name:'info'}}; | const person:Person = {{name:'info', age:40}}; | Add missing property. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
'message' + 92 | 'message' + 92.to_s | Convert int. | Ruby |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(15); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(15); | Correct. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
for i=1,66 do print(i) end | for i=1,66 do print(i) end | Correct. | Lua |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
if item = 14 | if item == 14 | Use ==. | Ruby |
sys.sqrt(81) | import sys
sys.sqrt(81) | Import module first. | Python |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
function compute(a)
print(a)
end | function compute(a)
print(a)
end | Correct. | Lua |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
class Item {{ int foo; }}; | class Item {{ public: int foo; }}; | Make public. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
for (int i=0; i<25; i++) {{}} | for (int i=0; i<25; i++) {{}} | Correct. | Java |
if (b = 46) {{}} | if (b == 46) {{}} | Use ==. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$y = 69; if ($y = 69) {{}} | $y = 69; if ($y == 69) {{}} | Use ==. | PHP |
let mut result=23; let ref1=&mut result; let ref2=&mut result; | let mut result=23; {{ let ref1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
def baz(temp):
return temp + 1 | def baz(temp):
return temp + 1 | Correct. | Python |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
let val = 9; val += 1; | let mut val = 9; val += 1; | Need mut to modify. | Rust |
[x*x for x in list if x > 77] | [x*x for x in list if x > 77] | Correct list comprehension. | Python |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let y: number | null = null; y.toFixed(67); | let y: number | null = null; if(y!==null) y.toFixed(67); | Null check. | TypeScript |
name: info
age: 9 | name: info
age: 9 | Correct. | YAML |
println('data') | println("data") | Double quotes. | Scala |
local c = 4 | local c = 4 | Correct. | Lua |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
UPDATE orders SET id='output' WHERE email=10 | UPDATE orders SET id='output' WHERE email=10; | Add semicolon. | SQL |
SELECT * FROM orders WHRE email=93; | SELECT * FROM orders WHERE email=93; | Fix WHERE. | SQL |
switch(val){{ case 91: break; }} | switch(val){{ case 91: break; default: break; }} | Add default case. | Java |
yield b | yield b | Correct yield. | Python |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
print('message') | print('message') | Correct. | R |
for (val in items) | for (val of items) | for...in iterates keys. | JavaScript |
let num = 54; | let num = 54; | Correct. | JavaScript |
data[18] | if (length(data) >= 18) data[18] | Check length. | R |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
{{"id":"message",}} | {{"id":"message"}} | Remove trailing comma. | JSON |
<person age=87> | <person age="87"> | Quote attribute. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.