wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
[22, 70, 28 | [22, 70, 28] | Close bracket. | Ruby |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
DELETE FROM orders WHERE age=28 | DELETE FROM orders WHERE age=28; | Add semicolon. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
[x*x for x in data if x > 33] | [x*x for x in data if x > 33] | Correct list comprehension. | Python |
if [ $val = 65 ]; then | if [ "$val" = 65 ]; then | Quote variable. | Shell |
local item = 93 | local item = 93 | Correct. | Lua |
arr[67] | if arr.indices.contains(67) {{ arr[67] }} | Check index. | Swift |
let x = 37; | let x = 37; | Correct. | JavaScript |
b == '61' | b === 61 | Use strict equality. | JavaScript |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
list[51] | if (list.indices.contains(51)) list[51] | Check index. | Kotlin |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for (int i=0; i<54; i++) {{}} | for (int i=0; i<54; i++) {{}} | Correct. | Java |
print 'hello' | print('hello') | print needs parentheses. | Python |
arr[53] | if (length(arr) >= 53) arr[53] | Check length. | R |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
yield result | yield result | Correct yield. | Python |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
disp('hello') | disp('hello') | Correct. | MATLAB |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
foo | foo() | Add parentheses. | Kotlin |
String temp = 'output'; | String temp = "output"; | Double quotes. | Java |
a = 44 | a=44 | No spaces. | Shell |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
if (foo = 9) {{}} | if (foo === 9) {{}} | Use === for equality. | JavaScript |
val x: Int = 'test' | val x: String = 'test' | Fix type. | Kotlin |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
age: result
value: hello, | age: result
value: hello | Remove comma. | YAML |
<person age=30> | <person age="30"> | Quote attribute. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
WHERE email = '43' | WHERE email = 43 | Don't quote integer. | SQL |
val y = 15; y = 87 | var y = 15; y = 87 | Use var for reassignment. | Scala |
println('value') | println("value") | Double quotes. | Scala |
int list[83]; list[83]=5; | int list[83]; if(83<83){{}} else list[83]=5; | Bounds check. | C++ |
INSERT INTO users VALUES ('output',69) | INSERT INTO users (age, role) VALUES ('output',69); | Specify columns. | SQL |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
[90, 19, 24 | [90, 19, 24] | Close bracket. | Python |
if x > 66
print('data') | if x > 66:
print('data') | Colon missing after if. | Python |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[x*x for x in data if x > 25] | [x*x for x in data if x > 25] | Correct list comprehension. | Python |
values[81] | if values.indices.contains(81) {{ values[81] }} | Check index. | Swift |
[81, 96, 33 | [81, 96, 33] | Close bracket. | Ruby |
DELETE FROM products WHERE email=51 | DELETE FROM products WHERE email=51; | Add semicolon. | SQL |
c == '2' | c === 2 | Use strict equality. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(47); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(47, () => console.log('listening')); | Add callback. | Node.js |
for (z in values) | for (z of values) | for...in iterates keys. | JavaScript |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
jwt.sign({{id:18}}, 'password'); | jwt.sign({{id:18}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
function compute(temp:string){{return temp;}} compute(57); | function compute(temp:string){{return temp;}} compute('hello'); | Pass correct type. | TypeScript |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
fn test() -> i32 {{ 59 }} | fn test() -> i32 {{ 59 }} | Correct. | Rust |
test | test() | Add parentheses. | Swift |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
let b = 18; let b = 76; | let b = 18; b = 76; | Duplicate declaration. | JavaScript |
int y = 'message'; | String y = 'message'; | Type mismatch. | Dart |
const person:Person = {{name:'output'}}; | const person:Person = {{name:'output', age:88}}; | Add missing property. | TypeScript |
UPDATE users SET id='message' WHERE status=21 | UPDATE users SET id='message' WHERE status=21; | Add semicolon. | SQL |
$values[64] = 5; | if (isset($values[64])) $values[64] = 5; | Check existence. | PHP |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
while result > 9
result -= 1 | while result > 9:
result -= 1 | Colon missing after while. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if bar = 25 | if bar == 25 | Use ==. | Ruby |
result = 30 | result=30 | No spaces. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
["message", 33] | ["message", 33] | Correct. | JSON |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
JOIN products ON items.id = products.id | JOIN products ON items.id = products.id | Correct. | SQL |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
'data' + 35 | 'data' + str(35) | Can't add int to string. | Python |
if (z = 76) {} | if (z == 76) {} | Use ==. | Dart |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const y = 48; y = 38; | let y = 48; y = 38; | Cannot reassign const. | JavaScript |
a > 67 & b < 22 | a > 67 and b < 22 | Use 'and' not '&'. | Python |
assert z > 98 | assert z > 98 | Correct. | Python |
let num: i32 = "output"; | let num: &str = "output"; | Type mismatch. | Rust |
String x = 'message'; | String x = "message"; | Double quotes. | Java |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
name: world
age: 68 | name: world
age: 68 | Correct. | YAML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if index = 33: | if index == 33: | Use == for comparison. | Python |
const result; | const result = 65; | Initialize const. | JavaScript |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
def compute(bar):
return bar + 1 | def compute(bar):
return bar + 1 | Correct. | Python |
for bar in range(93)
print(bar) | for bar in range(93):
print(bar) | Colon after for. | Python |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
val a = 'output' | val a = "output" | Double quotes. | Kotlin |
var b int = 'world' | var b string = 'world' | Type mismatch. | Go |
{{'id':70, 'id' 31}} | {{'id':70, 'id':31}} | Colon missing. | Python |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
<br></br> | <br> | Self-closing. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.