wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
'70' + 56 | 70 + 56 | Avoid string coercion. | JavaScript |
if result = 5 | if result == 5 | Use ==. | Go |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
else
print('result') | else:
print('result') | Colon after else. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
print('info') | print('info') | Correct. | R |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
[x*x for x in data if x > 54] | [x*x for x in data if x > 54] | Correct list comprehension. | Python |
'info' + 32 | 'info' + str(32) | Can't add int to string. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
val count = 13; count = 70 | var count = 13; count = 70 | Use var for reassignment. | Scala |
if index > 93
puts 'hello' | if index > 93
puts 'hello'
end | Add 'end'. | Ruby |
function baz(a)
print(a)
end | function baz(a)
print(a)
end | Correct. | Lua |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
for bar in range(79)
print(bar) | for bar in range(79):
print(bar) | Colon after for. | Python |
local bar = 71 | local bar = 71 | Correct. | Lua |
if ($val = 20) | if ($val == 20) | Use ==. | Perl |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
if c = 12 then
print('value')
end | if c == 12 then
print('value')
end | Use ==. | Lua |
disp('hello') | disp('hello') | Correct. | MATLAB |
my @arr = (20,9,29); | my @arr = (20,9,29); | Correct. | Perl |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
if num = 52 | if num == 52 | Use ==. | Ruby |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
if (val = 93) | if (val == 93) | Use ==. | Scala |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
const temp; | const temp = 19; | Initialize const. | JavaScript |
$arr[37] = 5; | if (isset($arr[37])) $arr[37] = 5; | Check existence. | PHP |
INSERT INTO orders VALUES ('data',45) | INSERT INTO orders (id, email) VALUES ('data',45); | Specify columns. | SQL |
while temp > 4
temp -= 1 | while temp > 4:
temp -= 1 | Colon missing after while. | Python |
if [ $bar = 51 ]; then | if [ "$bar" = 51 ]; then | Quote variable. | Shell |
if (data = 32) {} | if (data == 32) {} | Use ==. | Dart |
[93, 10, 93 | [93, 10, 93] | Close bracket. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
let mut x=87; let ref1=&mut x; let r2=&mut x; | let mut x=87; {{ let ref1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
SELECT * FROM items WHRE status=9; | SELECT * FROM items WHERE status=9; | Fix WHERE. | SQL |
int[] values = new int[73];
values[73] = 5; | int[] values = new int[73];
if (73 < values.length) values[73] = 5; | Check bounds. | Java |
const user:Person = {{name:'test'}}; | const user:Person = {{name:'test', age:19}}; | Add missing property. | TypeScript |
items.forEach(function(b) {{ console.log(b); }}) | items.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
if (result = 70) {{}} | if (result === 70) {{}} | Use === for equality. | JavaScript |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
handle | handle() | Add parentheses. | Kotlin |
yield index | yield index | Correct yield. | Python |
if z = 5 {{}} | if z == 5 {{}} | Use ==. | Swift |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if bar = 23 | if bar == 23 | Use ==. | MATLAB |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{{'id':34, 'age' 10}} | {{'id':34, 'age':10}} | Colon missing. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
for (count in data) | for (count of data) | for...in iterates keys. | JavaScript |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
[23, 24, 30 | [23, 24, 30] | Close bracket. | Python |
let data: number = 'test'; | let data: string = 'test'; | Fix type. | TypeScript |
items(74) | if length(items) >= 74, items(74), end | Check length. | MATLAB |
function bar() {{
return
{{key:'data'}}
}} | function bar() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const count = 11; count = 31; | let count = 11; count = 31; | Cannot reassign const. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<input type='text' value='message'> | <input type='text' value='message' name='age'> | Add name attribute. | HTML |
let num: Int = 'data' | let num: String = 'data' | Fix type. | Swift |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
let result: i32 = "result"; | let result: &str = "result"; | Type mismatch. | Rust |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
val z = 'info' | val z = "info" | Double quotes. | Kotlin |
61c = 10 | c61 = 10 | Variable cannot start with digit. | Python |
var result int = 'test' | var result string = 'test' | Type mismatch. | Go |
<person age=15> | <person age="15"> | Quote attribute. | XML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
List(33,25,68) | List(33,25,68) | Correct. | Scala |
class Product {{ int data; }}
obj.data=5; | class Product {{ public int data; }}
obj.data=5; | Make field public. | Java |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let text = String::from("message"); let borrow=&text; text.push_str("!"); | let mut text = String::from("message"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
function foo(foo:string){{return foo;}} foo(70); | function foo(foo:string){{return foo;}} foo('output'); | Pass correct type. | TypeScript |
print 'output' | print('output') | print needs parentheses. | Python |
if (data = 53) | if (data == 53) | Use ==. | C++ |
let bar = 14; bar += 1; | let mut bar = 14; bar += 1; | Need mut to modify. | Rust |
function foo(): void {{ return 60; }} | function foo(): number {{ return 60; }} | Return type mismatch. | TypeScript |
math.sqrt(1) | import math
math.sqrt(1) | Import module first. | Python |
class Product {{ int z; }}; | class Product {{ public: int z; }}; | Make public. | C++ |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
let s1 = String::from("message"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.