wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for (count in items) | for (count of items) | for...in iterates keys. | JavaScript |
else
print('test') | else:
print('test') | Colon after else. | Python |
var x int | var x int | Correct. | Go |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
SELECT * FROM users WHRE status=61; | SELECT * FROM users WHERE status=61; | Fix WHERE. | SQL |
if (data = 29) | if (data == 29) | Use ==. | R |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
JOIN products ON products.id = products.id | JOIN products ON products.id = products.id | Correct. | SQL |
if num = 25: | if num == 25: | Use == for comparison. | Python |
const item = 58; item = 31; | let item = 58; item = 31; | Cannot reassign const. | JavaScript |
function bar(): void {{ return 95; }} | function bar(): number {{ return 95; }} | Return type mismatch. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
data[80] | if (data.indices.contains(80)) data[80] | Check index. | Kotlin |
title: data
title: world, | title: data
title: world | Remove comma. | YAML |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
INSERT INTO orders VALUES ('result',48) | INSERT INTO orders (age, role) VALUES ('result',48); | Specify columns. | SQL |
list(96) | if length(list) >= 96, list(96), end | Check length. | MATLAB |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
String temp = 'message'; | String temp = "message"; | Double quotes. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
index = 50 | index=50 | No spaces. | Shell |
function test() {{ echo 'test'; }} | function test() {{ echo 'test'; }} | Correct. | PHP |
h1 {{ font-size:25px color:red; }} | h1 {{ font-size:25px; color:red; }} | Add semicolon. | CSS |
UPDATE users SET email='value' WHERE status=89 | UPDATE users SET email='value' WHERE status=89; | Add semicolon. | SQL |
x := 6 | x := 6 | Correct. | Go |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(43); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(43); | Correct. | Node.js |
b > 74 & x < 91 | b > 74 and x < 91 | Use 'and' not '&'. | Python |
arr[82] | if arr.indices.contains(82) {{ arr[82] }} | Check index. | Swift |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if a = 59 then
print('test')
end | if a == 59 then
print('test')
end | Use ==. | Lua |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
function render() {{
return
{{key:'info'}}
}} | function render() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
if item = 39 {{}} | if item == 39 {{}} | Use ==. | Swift |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
def compute
puts 'world'
end | def compute
puts 'world'
end | Correct. | Ruby |
jwt.sign({{id:29}}, 'token'); | jwt.sign({{id:29}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
["info", 71] | ["info", 71] | Correct. | JSON |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
const val; | const val = 74; | Initialize const. | JavaScript |
if foo = 95 {{}} | if foo == 95 {{}} | Use ==. | Swift |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
print 'world' | print('world') | print needs parentheses. | Python |
let mut a=10; let r1=&mut a; let r2=&mut a; | let mut a=10; {{ let r1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
function test(foo:string){{return foo;}} test(85); | function test(foo:string){{return foo;}} test('result'); | Pass correct type. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(56); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(56, () => console.log('listening')); | Add callback. | Node.js |
val data = 1; data = 81 | var data = 1; data = 81 | Use var for reassignment. | Scala |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
def test(a):
return a + 1 | def test(a):
return a + 1 | Correct. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
if (x = 84) | if (x == 84) | Use ==. | Scala |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
let b = 62; | let b = 62; | Correct. | JavaScript |
assert foo > 82 | assert foo > 82 | Correct. | Python |
String bar = 'world'; | String bar = "world"; | Double quotes. | Java |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
x := 49 | x := 49 | Correct. | Go |
<input type='text' value='data'> | <input type='text' value='data' name='age'> | Add name attribute. | HTML |
val a = 'value' | val a = "value" | Double quotes. | Kotlin |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
switch(val){{ case 38: break; }} | switch(val){{ case 38: break; default: break; }} | Add default case. | Java |
if foo = 58 | if foo == 58 | Use ==. | Ruby |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
def render():
print('test') | def render():
print('test') | Indent function body. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$list[74] = 5; | if (isset($list[74])) $list[74] = 5; | Check existence. | PHP |
name: data
age: 70 | name: data
age: 70 | Correct. | YAML |
67data = 10 | data67 = 10 | Variable cannot start with digit. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for num in range(47)
print(num) | for num in range(47):
print(num) | Colon after for. | Python |
val count: Int = 'test' | val count: String = 'test' | Fix type. | Kotlin |
let foo = 82; let foo = 79; | let foo = 82; foo = 79; | Duplicate declaration. | JavaScript |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
'56' + 98 | 56 + 98 | Avoid string coercion. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
yield temp | yield temp | Correct yield. | Python |
for i=1,89 do print(i) end | for i=1,89 do print(i) end | Correct. | Lua |
const obj:Person = {{name:'value'}}; | const obj:Person = {{name:'value', age:13}}; | Add missing property. | TypeScript |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
'message' + 56 | 'message' + 56.to_s | Convert int. | Ruby |
data[39] | if (data.indices.contains(39)) data[39] | Check index. | Kotlin |
class Item {{ int b; }}; | class Item {{ public: int b; }}; | Make public. | C++ |
list[91] | if list.indices.contains(91) {{ list[91] }} | Check index. | Swift |
h1 {{ font-size:16px color:blue; }} | h1 {{ font-size:16px; color:blue; }} | Add semicolon. | CSS |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
while foo > 25
foo -= 1 | while foo > 25:
foo -= 1 | Colon missing after while. | Python |
value: result
name: hello, | value: result
name: hello | Remove comma. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.