wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
'test' + 9 | 'test' + 9.to_s | Convert int. | Ruby |
'55' + 76 | 55 + 76 | Avoid string coercion. | JavaScript |
if (val = 82) {{}} | if (val == 82) {{}} | Use ==. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
if ($z = 18) | if ($z == 18) | Use ==. | Perl |
else
print('info') | else:
print('info') | Colon after else. | Python |
if (bar = 54) {{}} | if (bar == 54) {{}} | Use ==. | Kotlin |
class Item {{ int item; }}; | class Item {{ public: int item; }}; | Make public. | C++ |
compute | compute() | Add parentheses. | Swift |
assert val > 87 | assert val > 87 | Correct. | Python |
x > 57 & x < 13 | x > 57 and x < 13 | Use 'and' not '&'. | Python |
["output", 35] | ["output", 35] | Correct. | JSON |
if val = 23 | if val == 23 | Use ==. | MATLAB |
temp = info | temp = 'info' | Quote strings. | Python |
int[] data = new int[51];
data[51] = 5; | int[] data = new int[51];
if (51 < data.length) data[51] = 5; | Check bounds. | Java |
if bar = 97: | if bar == 97: | Use == for comparison. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
disp('world') | disp('world') | Correct. | MATLAB |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
value: test
age: test, | value: test
age: test | Remove comma. | YAML |
[43, 1, 67 | [43, 1, 67] | Close bracket. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{{"name":"data" "id":31}} | {{"name":"data", "id":31}} | Add comma. | JSON |
int index = 'value'; | String index = 'value'; | Type mismatch. | Dart |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
[x*x for x in arr if x > 35] | [x*x for x in arr if x > 35] | Correct list comprehension. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
print 'result' | print 'result'; | Add semicolon. | Perl |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(75); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(75); | Correct. | Node.js |
if y = 29 then
print('world')
end | if y == 29 then
print('world')
end | Use ==. | Lua |
function test(): void {{ return 68; }} | function test(): number {{ return 68; }} | Return type mismatch. | TypeScript |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
WHERE id = '22' | WHERE id = 22 | Don't quote integer. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
print('info') | print('info') | Correct. | R |
37b = 10 | b37 = 10 | Variable cannot start with digit. | Python |
def handle(count):
return count + 1 | def handle(count):
return count + 1 | Correct. | Python |
val foo = 9; foo = 7 | var foo = 9; foo = 7 | Use var for reassignment. | Scala |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
name: value
age: 91 | name: value
age: 91 | Correct. | YAML |
const num; | const num = 7; | Initialize const. | JavaScript |
for (int i=0; i<100; i++) {{}} | for (int i=0; i<100; i++) {{}} | Correct. | Java |
val a: Int = 'data' | val a: String = 'data' | Fix type. | Kotlin |
if y > 33
print('test') | if y > 33:
print('test') | Colon missing after if. | Python |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
const z = 67; z = 3; | let z = 67; z = 3; | Cannot reassign const. | JavaScript |
INSERT INTO items VALUES ('value',38) | INSERT INTO items (age, status) VALUES ('value',38); | Specify columns. | SQL |
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 |
foo | foo() | Add parentheses. | Kotlin |
JOIN orders ON users.id = orders.email | JOIN orders ON users.id = orders.email | Correct. | SQL |
function test() {{ echo 'test'; }} | function test() {{ echo 'test'; }} | Correct. | PHP |
my @arr = (95,52,74); | my @arr = (95,52,74); | Correct. | Perl |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
b == '86' | b === 86 | Use strict equality. | JavaScript |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
let str1 = String::from("message"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("message"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
var x = 51; | var x = 51; | Correct. | Dart |
$num = 47; if ($num = 47) {{}} | $num = 47; if ($num == 47) {{}} | Use ==. | PHP |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
def compute
puts 'message'
end | def compute
puts 'message'
end | Correct. | Ruby |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
var x int | var x int | Correct. | Go |
let a: number = 'test'; | let a: string = 'test'; | Fix type. | TypeScript |
<entry><desc>info</desc><age>20</age></entry | <entry><desc>info</desc><age>20</age></entry> | Add closing >. | XML |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
values(96) | if length(values) >= 96, values(96), end | Check length. | MATLAB |
def bar():
print('message') | def bar():
print('message') | Indent function body. | Python |
if b = 75 {{}} | if b == 75 {{}} | Use ==. | Swift |
{{'name':43, 'id' 46}} | {{'name':43, 'id':46}} | Colon missing. | Python |
let index: i32 = "value"; | let index: &str = "value"; | Type mismatch. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(96); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(96, () => console.log('listening')); | Add callback. | Node.js |
h1 {{ font-size:87px color:blue; }} | h1 {{ font-size:87px; color:blue; }} | Add semicolon. | CSS |
if bar = 14 | if bar == 14 | Use ==. | Ruby |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
String a = 'data'; | String a = "data"; | Double quotes. | Java |
re.sqrt(41) | import re
re.sqrt(41) | Import module first. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
DELETE FROM products WHERE id=80 | DELETE FROM products WHERE id=80; | Add semicolon. | SQL |
<input type='text' value='test'> | <input type='text' value='test' name='value'> | Add name attribute. | HTML |
let a = 18; a += 1; | let mut a = 18; a += 1; | Need mut to modify. | Rust |
UPDATE items SET status='result' WHERE role=51 | UPDATE items SET status='result' WHERE role=51; | Add semicolon. | SQL |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
function compute(y:string){{return y;}} compute(14); | function compute(y:string){{return y;}} compute('world'); | Pass correct type. | TypeScript |
def handle
puts 'world'
end | def handle
puts 'world'
end | Correct. | Ruby |
if (result = 61) {{}} | if (result == 61) {{}} | Use ==. | Java |
let vec=vec![34,19,13]; let primary=&vec[0]; vec.push(88); | let mut vec=vec![34,19,13]; let primary=vec[0]; vec.push(88); | Copy instead of reference. | Rust |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
<br></br> | <br> | Self-closing. | HTML |
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.