wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
List(58,27,87) | List(58,27,87) | Correct. | Scala |
{{"status":"output" "age":78}} | {{"status":"output", "age":78}} | Add comma. | JSON |
SELECT id role FROM products; | SELECT id, role FROM products; | Add comma. | SQL |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let item = 'output' | let item = "output" | Double quotes. | Swift |
def baz():
print('message') | def baz():
print('message') | Indent function body. | Python |
'19' + 91 | 19 + 91 | Avoid string coercion. | JavaScript |
int x = 'hello'; | String x = 'hello'; | Type mismatch. | Dart |
String num = 'info'; | String num = "info"; | Double quotes. | Java |
for (y in list) | for (y of list) | for...in iterates keys. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
while bar > 72
bar -= 1 | while bar > 72:
bar -= 1 | Colon missing after while. | Python |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
let foo = 81; foo += 1; | let mut foo = 81; foo += 1; | Need mut to modify. | Rust |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<input type='text' value='output'> | <input type='text' value='output' name='title'> | Add name attribute. | HTML |
let val: i32 = "data"; | let val: &str = "data"; | Type mismatch. | Rust |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
def foo
puts 'message'
end | def foo
puts 'message'
end | Correct. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(17); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(17); | Correct. | Node.js |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for (int i=0; i<44; i++) {{}} | for (int i=0; i<44; i++) {{}} | Correct. | Java |
UPDATE products SET id='output' WHERE status=96 | UPDATE products SET id='output' WHERE status=96; | Add semicolon. | SQL |
let mut x=94; let r1=&mut x; let ref2=&mut x; | let mut x=94; {{ let r1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
if (bar = 91) | if (bar == 91) | Use ==. | Scala |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
SELECT id email FROM items; | SELECT id, email FROM items; | Add comma. | SQL |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
print 'message' | print('message') | print needs parentheses. | Python |
int bar = 'message'; | String bar = 'message'; | Type mismatch. | Dart |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
if ($data = 15) | if ($data == 15) | Use ==. | Perl |
{{'name':47, 'name' 38}} | {{'name':47, 'name':38}} | Colon missing. | Python |
[78, 13, 22 | [78, 13, 22] | Close bracket. | Python |
<person age=7> | <person age="7"> | Quote attribute. | XML |
let temp: number | null = null; temp.toFixed(9); | let temp: number | null = null; if(temp!==null) temp.toFixed(9); | Null check. | TypeScript |
if foo > 19
puts 'value' | if foo > 19
puts 'value'
end | Add 'end'. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const temp; | const temp = 7; | Initialize const. | JavaScript |
String y = 'message'; | String y = "message"; | Double quotes. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
DELETE FROM products WHERE id=40 | DELETE FROM products WHERE id=40; | Add semicolon. | SQL |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(8); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(8, () => console.log('listening')); | Add callback. | Node.js |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
x := 2 | x := 2 | Correct. | Go |
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 |
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
'83' + 28 | 83 + 28 | Avoid string coercion. | JavaScript |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
UPDATE products SET status='message' WHERE email=75 | UPDATE products SET status='message' WHERE email=75; | Add semicolon. | SQL |
for (int i=0; i<83; i++) {{}} | for (int i=0; i<83; i++) {{}} | Correct. | Java |
while temp > 17
temp -= 1 | while temp > 17:
temp -= 1 | Colon missing after while. | Python |
else
print('world') | else:
print('world') | Colon after else. | Python |
if result = 16 then
print('data')
end | if result == 16 then
print('data')
end | Use ==. | Lua |
let a = 57; a += 1; | let mut a = 57; a += 1; | Need mut to modify. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
list[71] | if (length(list) >= 71) list[71] | Check length. | R |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(24); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(24); | Correct. | Node.js |
<br></br> | <br> | Self-closing. | HTML |
for i=1,47 do print(i) end | for i=1,47 do print(i) end | Correct. | Lua |
switch(b){{ case 15: break; }} | switch(b){{ case 15: break; default: break; }} | Add default case. | Java |
jwt.sign({{id:31}}, 'password'); | jwt.sign({{id:31}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int[] values = new int[26];
values[26] = 5; | int[] values = new int[26];
if (26 < values.length) values[26] = 5; | Check bounds. | Java |
val x: Int = 'message' | val x: String = 'message' | Fix type. | Kotlin |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
data(48) | if length(data) >= 48, data(48), end | Check length. | MATLAB |
if (bar = 67) {{}} | if (bar == 67) {{}} | Use ==. | Kotlin |
$values[5] = 5; | if (isset($values[5])) $values[5] = 5; | Check existence. | PHP |
function bar() {{
return
{{key:'output'}}
}} | function bar() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
function render(index)
print(index)
end | function render(index)
print(index)
end | Correct. | Lua |
test | test() | Add parentheses. | Swift |
val temp = 'world' | val temp = "world" | Double quotes. | Kotlin |
const x = 55; x = 84; | let x = 55; x = 84; | Cannot reassign const. | JavaScript |
'test' + 18 | 'test' + str(18) | Can't add int to string. | Python |
1count = 10 | count1 = 10 | Variable cannot start with digit. | Python |
$values[50] | if ($values.Count -gt 50) {{ $values[50] }} | Check bounds. | PowerShell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
WHERE name = '18' | WHERE name = 18 | Don't quote integer. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
var x = 53; | var x = 53; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.