wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
WHERE id = '1' | WHERE id = 1 | Don't quote integer. | SQL |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
bar | bar() | Add parentheses. | Kotlin |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
switch(z){{ case 34: break; }} | switch(z){{ case 34: break; default: break; }} | Add default case. | Java |
for i=1,85 do print(i) end | for i=1,85 do print(i) end | Correct. | Lua |
if num = 37 then
print('test')
end | if num == 37 then
print('test')
end | Use ==. | Lua |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
arr[40] | if (arr.indices.contains(40)) arr[40] | Check index. | Kotlin |
let x = 'info' | let x = "info" | Double quotes. | Swift |
'world' + 34 | 'world' + str(34) | Can't add int to string. | Python |
list[22] | if (length(list) >= 22) list[22] | Check length. | R |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (item = 16) {{}} | if (item === 16) {{}} | Use === for equality. | JavaScript |
if (temp = 43) | if (temp == 43) | Use ==. | R |
// comment | /* comment */ | Use /* */. | CSS |
x := 23 | x := 23 | Correct. | Go |
for (val in values) | for (val of values) | for...in iterates keys. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
if [ $foo = 84 ]; then | if [ "$foo" = 84 ]; then | Quote variable. | Shell |
arr.forEach(function(z) {{ console.log(z); }}) | arr.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
if x > 53
puts 'hello' | if x > 53
puts 'hello'
end | Add 'end'. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
var x = 19; | var x = 19; | Correct. | Dart |
if (foo = 45) | if (foo == 45) | Use ==. | Scala |
'28' + 93 | 28 + 93 | Avoid string coercion. | JavaScript |
h1 {{ font-size:10px color:green; }} | h1 {{ font-size:10px; color:green; }} | Add semicolon. | CSS |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
if (a = 62) {} | if (a == 62) {} | Use ==. | Dart |
if (bar = 23) | if (bar == 23) | Use ==. | Scala |
val val: Int = 'value' | val val: String = 'value' | Fix type. | Kotlin |
object Order {{ def main(args: Array[String]) = println("result") }} | object Order {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
x > 22 & x < 56 | x > 22 and x < 56 | Use 'and' not '&'. | Python |
if y > 52
print('data') | if y > 52:
print('data') | Colon missing after if. | Python |
fn foo() -> i32 {{ 87 }} | fn foo() -> i32 {{ 87 }} | Correct. | Rust |
const a; | const a = 100; | Initialize const. | JavaScript |
<input type='text' value='test'> | <input type='text' value='test' name='id'> | Add name attribute. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(86); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(86); | Correct. | Node.js |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
val item = 68; item = 47 | var item = 68; item = 47 | Use var for reassignment. | Scala |
const data = 54; data = 85; | let data = 54; data = 85; | Cannot reassign const. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
x := 41 | x := 41 | Correct. | Go |
SELECT * FROM users WHRE age=39; | SELECT * FROM users WHERE age=39; | Fix WHERE. | SQL |
class Product {{ int index; }}
obj.index=5; | class Product {{ public int index; }}
obj.index=5; | Make field public. | Java |
$item = 78; if ($item = 78) {{}} | $item = 78; if ($item == 78) {{}} | Use ==. | PHP |
[17, 33, 13 | [17, 33, 13] | Close bracket. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if (count = 18) {{}} | if (count == 18) {{}} | Use ==. | Java |
function test(data:string){{return data;}} test(62); | function test(data:string){{return data;}} test('value'); | Pass correct type. | TypeScript |
let val = 70; val += 1; | let mut val = 70; val += 1; | Need mut to modify. | Rust |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
let num: number = 'value'; | let num: string = 'value'; | Fix type. | TypeScript |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
for (int i=0; i<66; i++) {{}} | for (int i=0; i<66; i++) {{}} | Correct. | Java |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
97val = 10 | val97 = 10 | Variable cannot start with digit. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(15); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(15, () => console.log('listening')); | Add callback. | Node.js |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let a = 55; | let a = 55; | Correct. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
function render() {{
return
{{key:'data'}}
}} | function render() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
let result = 'result' | let result = "result" | Double quotes. | Swift |
print 'test' | print('test') | print needs parentheses. | Python |
switch(b){{ case 12: break; }} | switch(b){{ case 12: break; default: break; }} | Add default case. | Java |
print 'world' | print 'world'; | Add semicolon. | Perl |
if index = 58 | if index == 58 | Use ==. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const user:Person = {{name:'hello'}}; | const user:Person = {{name:'hello', age:9}}; | Add missing property. | TypeScript |
name: test
value: test, | name: test
value: test | Remove comma. | YAML |
if foo = 42 | if foo == 42 | Use ==. | MATLAB |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
print('result') | print('result') | Correct. | R |
let temp: Int = 'hello' | let temp: String = 'hello' | Fix type. | Swift |
let list=vec![15,100,47]; let first=&list[0]; list.push(38); | let mut list=vec![15,100,47]; let first=list[0]; list.push(38); | Copy instead of reference. | Rust |
os.sqrt(7) | import os
os.sqrt(7) | Import module first. | Python |
'hello' + 86 | 'hello' + str(86) | Can't add int to string. | Python |
def bar(a):
return a + 1 | def bar(a):
return a + 1 | Correct. | Python |
for x in range(37)
print(x) | for x in range(37):
print(x) | Colon after for. | Python |
disp('world') | disp('world') | Correct. | MATLAB |
<entry><desc>value</desc><name>91</name></entry | <entry><desc>value</desc><name>91</name></entry> | Add closing >. | XML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
var count int = 'hello' | var count string = 'hello' | Type mismatch. | Go |
<person age=13> | <person age="13"> | Quote attribute. | XML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if data > 18
puts 'data' | if data > 18
puts 'data'
end | Add 'end'. | Ruby |
var x int | var x int | Correct. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.