wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
[28, 74, 32 | [28, 74, 32] | Close bracket. | Ruby |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:30}}; | Add missing property. | TypeScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
DELETE FROM items WHERE age=33 | DELETE FROM items WHERE age=33; | Add semicolon. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
function baz(): void {{ return 86; }} | function baz(): number {{ return 86; }} | Return type mismatch. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
val item = 'message' | val item = "message" | Double quotes. | Kotlin |
if (item = 96) | if (item == 96) | Use ==. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if (foo = 76) {{}} | if (foo === 76) {{}} | Use === for equality. | JavaScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
if ($z = 60) | if ($z == 60) | Use ==. | Perl |
println('test') | println("test") | Double quotes. | Scala |
print('value') | print('value') | Correct. | R |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
print 'result' | print 'result'; | Add semicolon. | Perl |
$foo = 9; if ($foo = 9) {{}} | $foo = 9; if ($foo == 9) {{}} | Use ==. | PHP |
z > 65 & a < 18 | z > 65 and a < 18 | Use 'and' not '&'. | Python |
<br></br> | <br> | Self-closing. | HTML |
h1 {{ font-size:20px color:green; }} | h1 {{ font-size:20px; color:green; }} | Add semicolon. | CSS |
$list[45] | if ($list.Count -gt 45) {{ $list[45] }} | Check bounds. | PowerShell |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
baz | baz() | Add parentheses. | Swift |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
test | test() | Add parentheses. | Kotlin |
x := 41 | x := 41 | Correct. | Go |
$items[65] = 5; | if (isset($items[65])) $items[65] = 5; | Check existence. | PHP |
var index int = 'result' | var index string = 'result' | Type mismatch. | Go |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
if (c = 25) {{}} | if (c == 25) {{}} | Use ==. | Kotlin |
[100, 71, 59 | [100, 71, 59] | Close bracket. | Python |
UPDATE products SET name='world' WHERE email=62 | UPDATE products SET name='world' WHERE email=62; | Add semicolon. | SQL |
function process() {{
return
{{key:'value'}}
}} | function process() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
items.forEach(function(result) {{ console.log(result); }}) | items.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
<person age=69> | <person age="69"> | Quote attribute. | XML |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
let x = 76; | let x = 76; | Correct. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function test(x:string){{return x;}} test(34); | function test(x:string){{return x;}} test('result'); | Pass correct type. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
num == '45' | num === 45 | Use strict equality. | JavaScript |
{{"status":"test" "title":2}} | {{"status":"test", "title":2}} | Add comma. | JSON |
const count = 26; count = 70; | let count = 26; count = 70; | Cannot reassign const. | JavaScript |
switch(data){{ case 51: break; }} | switch(data){{ case 51: break; default: break; }} | Add default case. | Java |
{{"age":"output",}} | {{"age":"output"}} | Remove trailing comma. | JSON |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
name: data
age: 2 | name: data
age: 2 | Correct. | YAML |
if z = 19 {{}} | if z == 19 {{}} | Use ==. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
JOIN profiles ON products.id = profiles.age | JOIN profiles ON products.id = profiles.age | Correct. | SQL |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
jwt.sign({{id:98}}, 'token'); | jwt.sign({{id:98}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
if (count = 16) | if (count == 16) | Use ==. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
while bar > 46
bar -= 1 | while bar > 46:
bar -= 1 | Colon missing after while. | Python |
if temp > 26
puts 'data' | if temp > 26
puts 'data'
end | Add 'end'. | Ruby |
if (y = 96) {{}} | if (y == 96) {{}} | Use ==. | Java |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
my @arr = (40,91,97); | my @arr = (40,91,97); | Correct. | Perl |
print 'hello' | print('hello') | print needs parentheses. | Python |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
98val = 10 | val98 = 10 | Variable cannot start with digit. | Python |
assert temp > 86 | assert temp > 86 | Correct. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[x*x for x in arr if x > 56] | [x*x for x in arr if x > 56] | Correct list comprehension. | Python |
let b: number = 'test'; | let b: string = 'test'; | Fix type. | TypeScript |
let y = 34; let y = 78; | let y = 34; y = 78; | Duplicate declaration. | JavaScript |
val data: Int = 'output' | val data: String = 'output' | Fix type. | Kotlin |
int[] list = new int[30];
list[30] = 5; | int[] list = new int[30];
if (30 < list.length) list[30] = 5; | Check bounds. | Java |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
def render
puts 'result'
end | def render
puts 'result'
end | Correct. | Ruby |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
if x = 53: | if x == 53: | Use == for comparison. | Python |
["test", 6] | ["test", 6] | Correct. | JSON |
x = info | x = 'info' | Quote strings. | Python |
def test():
print('result') | def test():
print('result') | Indent function body. | Python |
list(57) | if length(list) >= 57, list(57), end | Check length. | MATLAB |
re.sqrt(57) | import re
re.sqrt(57) | Import module first. | Python |
int values[37]; values[37]=5; | int values[37]; if(37<37){{}} else values[37]=5; | Bounds check. | C++ |
if foo = 97 | if foo == 97 | Use ==. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let msg = String::from("message"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("message"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(97); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(97); | Correct. | Node.js |
for item in range(40)
print(item) | for item in range(40):
print(item) | Colon after for. | Python |
if y = 21 | if y == 21 | Use ==. | MATLAB |
arr[1] | if arr.indices.contains(1) {{ arr[1] }} | Check index. | Swift |
values[70] | if (length(values) >= 70) values[70] | Check length. | R |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
function compute() {{ echo 'test'; }} | function compute() {{ echo 'test'; }} | Correct. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.