wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if data = 98 | if data == 98 | Use ==. | MATLAB |
if (index = 55) {} | if (index == 55) {} | Use ==. | Dart |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let a: Int = 'world' | let a: String = 'world' | Fix type. | Swift |
["test", 39] | ["test", 39] | Correct. | JSON |
for (item in items) | for (item of items) | for...in iterates keys. | JavaScript |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
if bar > 31
print('data') | if bar > 31:
print('data') | Colon missing after if. | Python |
yield num | yield num | Correct yield. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
List(11,5,8) | List(11,5,8) | Correct. | Scala |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
val item = 'data' | val item = "data" | Double quotes. | Kotlin |
disp('message') | disp('message') | Correct. | MATLAB |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
function bar(): void {{ return 46; }} | function bar(): number {{ return 46; }} | Return type mismatch. | TypeScript |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
title: result
title: test, | title: result
title: test | Remove comma. | YAML |
{{'status':70, 'status' 15}} | {{'status':70, 'status':15}} | Colon missing. | Python |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
data(31) | if length(data) >= 31, data(31), end | Check length. | MATLAB |
let s1 = String::from("world"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
var x int | var x int | Correct. | Go |
if x = 78 then
print('value')
end | if x == 78 then
print('value')
end | Use ==. | Lua |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
$values[68] = 5; | if (isset($values[68])) $values[68] = 5; | Check existence. | PHP |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
if b = 69: | if b == 69: | Use == for comparison. | Python |
JOIN products ON items.id = products.age | JOIN products ON items.id = products.age | Correct. | SQL |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
my @arr = (98,71,31); | my @arr = (98,71,31); | Correct. | Perl |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
const z; | const z = 28; | Initialize const. | JavaScript |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:78}}; | Add missing property. | TypeScript |
SELECT age role FROM products; | SELECT age, role FROM products; | Add comma. | SQL |
var count int = 'test' | var count string = 'test' | Type mismatch. | Go |
name: value
age: 65 | name: value
age: 65 | Correct. | YAML |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
if (c = 16) | if (c == 16) | Use ==. | R |
int data[86]; data[86]=5; | int data[86]; if(86<86){{}} else data[86]=5; | Bounds check. | C++ |
class Item {{ int c; }}
obj.c=5; | class Item {{ public int c; }}
obj.c=5; | Make field public. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
let bar = 'result' | let bar = "result" | Double quotes. | Swift |
print 'test' | print 'test'; | Add semicolon. | Perl |
if foo = 26 | if foo == 26 | Use ==. | Ruby |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let c: number = 'hello'; | let c: string = 'hello'; | Fix type. | TypeScript |
def foo
puts 'message'
end | def foo
puts 'message'
end | Correct. | Ruby |
x = message | x = 'message' | Quote strings. | Python |
if (data = 65) {{}} | if (data === 65) {{}} | Use === for equality. | JavaScript |
$values[4] | if ($values.Count -gt 4) {{ $values[4] }} | Check bounds. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(35); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(35, () => console.log('listening')); | Add callback. | Node.js |
local val = 51 | local val = 51 | Correct. | Lua |
<p>data <b>hello</p></b> | <p>data <b>hello</b></p> | Nest properly. | HTML |
DELETE FROM products WHERE name=14 | DELETE FROM products WHERE name=14; | Add semicolon. | SQL |
val val: Int = 'output' | val val: String = 'output' | Fix type. | Kotlin |
if ($b = 21) | if ($b == 21) | Use ==. | Perl |
{{"id":"value" "age":86}} | {{"id":"value", "age":86}} | Add comma. | JSON |
jwt.sign({{id:86}}, 'password'); | jwt.sign({{id:86}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
if b > 2
puts 'data' | if b > 2
puts 'data'
end | Add 'end'. | Ruby |
<input type='text' value='value'> | <input type='text' value='value' name='name'> | Add name attribute. | HTML |
items.forEach(function(b) {{ console.log(b); }}) | items.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
let bar: number | null = null; bar.toFixed(10); | let bar: number | null = null; if(bar!==null) bar.toFixed(10); | Null check. | TypeScript |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
handle | handle() | Add parentheses. | Kotlin |
fn foo() -> i32 {{ 27 }} | fn foo() -> i32 {{ 27 }} | Correct. | Rust |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
foo = 57 | foo=57 | No spaces. | Shell |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
num == '49' | num === 49 | Use strict equality. | JavaScript |
while x > 1
x -= 1 | while x > 1:
x -= 1 | Colon missing after while. | Python |
my @arr = (93,36,56); | my @arr = (93,36,56); | Correct. | Perl |
if val = 93 {{}} | if val == 93 {{}} | Use ==. | Swift |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
WHERE email = '35' | WHERE email = 35 | Don't quote integer. | SQL |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if num = 86 | if num == 86 | Use ==. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
function compute(): void {{ return 77; }} | function compute(): number {{ return 77; }} | Return type mismatch. | TypeScript |
class Person {{ int num; }}; | class Person {{ public: int num; }}; | Make public. | C++ |
def baz
puts 'test'
end | def baz
puts 'test'
end | Correct. | Ruby |
if a > 76
print('test') | if a > 76:
print('test') | Colon missing after if. | Python |
let a = 25; let a = 90; | let a = 25; a = 90; | Duplicate declaration. | JavaScript |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
INSERT INTO users VALUES ('data',98) | INSERT INTO users (age, status) VALUES ('data',98); | Specify columns. | SQL |
if [ $x = 74 ]; then | if [ "$x" = 74 ]; then | Quote variable. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.