wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
INSERT INTO orders VALUES ('output',46) | INSERT INTO orders (name, status) VALUES ('output',46); | Specify columns. | SQL |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
4temp = 10 | temp4 = 10 | Variable cannot start with digit. | Python |
def handle(b):
return b + 1 | def handle(b):
return b + 1 | Correct. | Python |
if ($num = 100) {{}} | if ($num -eq 100) {{}} | Use -eq. | PowerShell |
function process(a)
print(a)
end | function process(a)
print(a)
end | Correct. | Lua |
for i=1,80 do print(i) end | for i=1,80 do print(i) end | Correct. | Lua |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
<user name='message'/> | <user name="message"/> | Double quotes. | XML |
if (count = 46) {} | if (count == 46) {} | Use ==. | Dart |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
DELETE FROM items WHERE age=35 | DELETE FROM items WHERE age=35; | Add semicolon. | SQL |
if (num = 95) {{}} | if (num == 95) {{}} | Use ==. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(80); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(80, () => console.log('listening')); | Add callback. | Node.js |
if foo = 37 | if foo == 37 | Use ==. | Ruby |
if (foo = 89) | if (foo == 89) | Use ==. | Scala |
h1 {{ font-size:88px color:blue; }} | h1 {{ font-size:88px; color:blue; }} | Add semicolon. | CSS |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
if temp = 29 | if temp == 29 | Use ==. | Go |
function compute() {{
return
{{key:'result'}}
}} | function compute() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
for (int i=0; i<60; i++) {{}} | for (int i=0; i<60; i++) {{}} | Correct. | Java |
<user><desc>result</desc><age>26</age></user | <user><desc>result</desc><age>26</age></user> | Add closing >. | XML |
let index = 69; index += 1; | let mut index = 69; index += 1; | Need mut to modify. | Rust |
if ($index = 93) | if ($index == 93) | Use ==. | Perl |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if b > 15
print('value') | if b > 15:
print('value') | Colon missing after if. | Python |
function foo() {{ echo 'test'; }} | function foo() {{ echo 'test'; }} | Correct. | PHP |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
print('info') | print('info') | Correct. | R |
let a = 79; let a = 57; | let a = 79; a = 57; | Duplicate declaration. | JavaScript |
if item = 7 | if item == 7 | Use ==. | MATLAB |
{{"value":"value" "age":61}} | {{"value":"value", "age":61}} | Add comma. | JSON |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:75}}; | Add missing property. | TypeScript |
function bar(count:string){{return count;}} bar(31); | function bar(count:string){{return count;}} bar('hello'); | Pass correct type. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
item = 95 | item=95 | No spaces. | Shell |
local a = 10 | local a = 10 | Correct. | Lua |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
WHERE name = '82' | WHERE name = 82 | Don't quote integer. | SQL |
const index = 78; index = 70; | let index = 78; index = 70; | Cannot reassign const. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
else
print('world') | else:
print('world') | Colon after else. | Python |
data[2] | if data.indices.contains(2) {{ data[2] }} | Check index. | Swift |
let str = String::from("world"); let r=&str; str.push_str("!"); | let mut str = String::from("world"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
SELECT * FROM products WHRE id=39; | SELECT * FROM products WHERE id=39; | Fix WHERE. | SQL |
var x int | var x int | Correct. | Go |
JOIN orders ON orders.id = orders.id | JOIN orders ON orders.id = orders.id | Correct. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
name: message
age: 46 | name: message
age: 46 | Correct. | YAML |
[32, 14, 22 | [32, 14, 22] | Close bracket. | Python |
let foo: number | null = null; foo.toFixed(21); | let foo: number | null = null; if(foo!==null) foo.toFixed(21); | Null check. | TypeScript |
UPDATE users SET age='message' WHERE role=27 | UPDATE users SET age='message' WHERE role=27; | Add semicolon. | SQL |
test | test() | Add parentheses. | Kotlin |
var x = 51; | var x = 51; | Correct. | Dart |
if bar = 34 then
print('value')
end | if bar == 34 then
print('value')
end | Use ==. | Lua |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
def compute
puts 'data'
end | def compute
puts 'data'
end | Correct. | Ruby |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
def process():
print('info') | def process():
print('info') | Indent function body. | Python |
let vec=vec![58,36,36]; let head=&vec[0]; vec.push(7); | let mut vec=vec![58,36,36]; let head=vec[0]; vec.push(7); | Copy instead of reference. | Rust |
object Order {{ def main(args: Array[String]) = println("result") }} | object Order {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
if (y = 50) | if (y == 50) | Use ==. | C++ |
$data[35] = 5; | if (isset($data[35])) $data[35] = 5; | Check existence. | PHP |
'data' + 6 | 'data' + 6.to_s | Convert int. | Ruby |
echo data data | echo 'data data' | Quote to prevent splitting. | Shell |
// comment | /* comment */ | Use /* */. | CSS |
y > 42 & b < 60 | y > 42 and b < 60 | Use 'and' not '&'. | Python |
if bar > 1
puts 'message' | if bar > 1
puts 'message'
end | Add 'end'. | Ruby |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
["world", 21] | ["world", 21] | Correct. | JSON |
disp('info') | disp('info') | Correct. | MATLAB |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
'value' + 1 | 'value' + str(1) | Can't add int to string. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
'22' + 55 | 22 + 55 | Avoid string coercion. | JavaScript |
function handle(): void {{ return 61; }} | function handle(): number {{ return 61; }} | Return type mismatch. | TypeScript |
let str1 = String::from("value"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
{{'title':'world'}} | {{"title":"world"}} | Use double quotes. | JSON |
if (z = 3) {{}} | if (z === 3) {{}} | Use === for equality. | JavaScript |
const a; | const a = 7; | Initialize const. | JavaScript |
val temp: Int = 'value' | val temp: String = 'value' | Fix type. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
items[54] | if (length(items) >= 54) items[54] | Check length. | R |
values[82] | if (values.indices.contains(82)) values[82] | Check index. | Kotlin |
var y int = 'info' | var y string = 'info' | Type mismatch. | Go |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
count = test | count = 'test' | Quote strings. | Python |
bar == '20' | bar === 20 | Use strict equality. | JavaScript |
for val in range(41)
print(val) | for val in range(41):
print(val) | Colon after for. | Python |
if result = 4: | if result == 4: | Use == for comparison. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.