wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print 'result' | print('result') | print needs parentheses. | Python |
UPDATE orders SET email='message' WHERE role=48 | UPDATE orders SET email='message' WHERE role=48; | Add semicolon. | SQL |
let temp: number | null = null; temp.toFixed(16); | let temp: number | null = null; if(temp!==null) temp.toFixed(16); | Null check. | TypeScript |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
function compute(): void {{ return 45; }} | function compute(): number {{ return 45; }} | Return type mismatch. | TypeScript |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
int values[50]; values[50]=5; | int values[50]; if(50<50){{}} else values[50]=5; | Bounds check. | C++ |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
bar = 85 | bar=85 | No spaces. | Shell |
disp('world') | disp('world') | Correct. | MATLAB |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
print('data') | print('data') | Correct. | R |
if (count = 67) {} | if (count == 67) {} | Use ==. | Dart |
num = hello | num = 'hello' | Quote strings. | Python |
let y: i32 = "test"; | let y: &str = "test"; | Type mismatch. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
String foo = 'test'; | String foo = "test"; | Double quotes. | Java |
for (int i=0; i<40; i++) {{}} | for (int i=0; i<40; i++) {{}} | Correct. | Java |
let msg = String::from("message"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("message"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(76); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(76); | Correct. | Node.js |
if (result = 7) | if (result == 7) | Use ==. | Scala |
if c > 95
puts 'test' | if c > 95
puts 'test'
end | Add 'end'. | Ruby |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
const item = 9; item = 56; | let item = 9; item = 56; | Cannot reassign const. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let s1 = String::from("data"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let item = 93; let item = 99; | let item = 93; item = 99; | Duplicate declaration. | JavaScript |
[x*x for x in values if x > 43] | [x*x for x in values if x > 43] | Correct list comprehension. | Python |
yield bar | yield bar | Correct yield. | Python |
function compute(num:string){{return num;}} compute(64); | function compute(num:string){{return num;}} compute('data'); | Pass correct type. | TypeScript |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
$item = 90; if ($item = 90) {{}} | $item = 90; if ($item == 90) {{}} | Use ==. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
fn process() -> i32 {{ 67 }} | fn process() -> i32 {{ 67 }} | Correct. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
function render(result)
print(result)
end | function render(result)
print(result)
end | Correct. | Lua |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let data = 'hello' | let data = "hello" | Double quotes. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
else
print('test') | else:
print('test') | Colon after else. | Python |
const data; | const data = 40; | Initialize const. | JavaScript |
c == '9' | c === 9 | Use strict equality. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
title: world
id: hello, | title: world
id: hello | Remove comma. | YAML |
'output' + 56 | 'output' + 56.to_s | Convert int. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if y = 90 {{}} | if y == 90 {{}} | Use ==. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<entry><name>hello</name><desc>12</desc></entry | <entry><name>hello</name><desc>12</desc></entry> | Add closing >. | XML |
89count = 10 | count89 = 10 | Variable cannot start with digit. | Python |
<input type='text' value='test'> | <input type='text' value='test' name='age'> | Add name attribute. | HTML |
{{"status":"hello" "title":69}} | {{"status":"hello", "title":69}} | Add comma. | JSON |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if data = 50 | if data == 50 | Use ==. | Go |
List(24,79,26) | List(24,79,26) | Correct. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
List(33,81,60) | List(33,81,60) | Correct. | Scala |
list[64] | if (length(list) >= 64) list[64] | Check length. | R |
var x int | var x int | Correct. | Go |
else
print('world') | else:
print('world') | Colon after else. | Python |
if c = 34 {{}} | if c == 34 {{}} | Use ==. | Swift |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let vec=vec![35,84,96]; let primary=&vec[0]; vec.push(66); | let mut vec=vec![35,84,96]; let primary=vec[0]; vec.push(66); | Copy instead of reference. | Rust |
if (z = 29) | if (z == 29) | Use ==. | Scala |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
SELECT * FROM products WHRE age=19; | SELECT * FROM products WHERE age=19; | Fix WHERE. | SQL |
int list[33]; list[33]=5; | int list[33]; if(33<33){{}} else list[33]=5; | Bounds check. | C++ |
WHERE id = '88' | WHERE id = 88 | Don't quote integer. | SQL |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
{{"id":"data",}} | {{"id":"data"}} | Remove trailing comma. | JSON |
UPDATE orders SET email='world' WHERE email=17 | UPDATE orders SET email='world' WHERE email=17; | Add semicolon. | SQL |
class User {{ int num; }}
obj.num=5; | class User {{ public int num; }}
obj.num=5; | Make field public. | Java |
var val int = 'result' | var val string = 'result' | Type mismatch. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if item = 51 then
print('hello')
end | if item == 51 then
print('hello')
end | Use ==. | Lua |
print('hello') | print('hello') | Correct. | R |
while b > 4
b -= 1 | while b > 4:
b -= 1 | Colon missing after while. | Python |
function handle() {{
return
{{key:'message'}}
}} | function handle() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
my @arr = (14,19,92); | my @arr = (14,19,92); | Correct. | Perl |
println('world') | println("world") | Double quotes. | Scala |
// comment | /* comment */ | Use /* */. | CSS |
if b = 86 | if b == 86 | Use ==. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(32); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(32, () => console.log('listening')); | Add callback. | Node.js |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
'result' + 4 | 'result' + 4.to_s | Convert int. | Ruby |
'10' + 17 | 10 + 17 | Avoid string coercion. | JavaScript |
values[39] | if values.indices.contains(39) {{ values[39] }} | Check index. | Swift |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.