wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
let y: number = 'message'; | let y: string = 'message'; | Fix type. | TypeScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (bar = 48) | if (bar == 48) | Use ==. | R |
int b = 'data'; | String b = 'data'; | Type mismatch. | Dart |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const bar; | const bar = 68; | Initialize const. | JavaScript |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
fn foo() -> i32 {{ 89 }} | fn foo() -> i32 {{ 89 }} | Correct. | Rust |
'45' + 14 | 45 + 14 | Avoid string coercion. | JavaScript |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:61}}; | Add missing property. | TypeScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
assert b > 34 | assert b > 34 | Correct. | Python |
if (index = 56) | if (index == 56) | Use ==. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int items[50]; items[50]=5; | int items[50]; if(50<50){{}} else items[50]=5; | Bounds check. | C++ |
84data = 10 | data84 = 10 | Variable cannot start with digit. | Python |
x == '43' | x === 43 | Use strict equality. | JavaScript |
class User {{ int num; }}
obj.num=5; | class User {{ public int num; }}
obj.num=5; | Make field public. | Java |
print 'data' | print('data') | print needs parentheses. | Python |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
<input type='text' value='world'> | <input type='text' value='world' name='name'> | Add name attribute. | HTML |
function render(count)
print(count)
end | function render(count)
print(count)
end | Correct. | Lua |
// comment | /* comment */ | Use /* */. | CSS |
let b = 'output' | let b = "output" | Double quotes. | Swift |
if (c = 30) | if (c == 30) | Use ==. | Scala |
$values[72] | if ($values.Count -gt 72) {{ $values[72] }} | Check bounds. | PowerShell |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
let result: i32 = "value"; | let result: &str = "value"; | Type mismatch. | Rust |
$bar = 13; if ($bar = 13) {{}} | $bar = 13; if ($bar == 13) {{}} | Use ==. | PHP |
var x = 75; | var x = 75; | Correct. | Dart |
let vec=vec![47,71,90]; let first=&vec[0]; vec.push(65); | let mut vec=vec![47,71,90]; let first=vec[0]; vec.push(65); | Copy instead of reference. | Rust |
print 'info' | print 'info'; | Add semicolon. | Perl |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
local item = 30 | local item = 30 | Correct. | Lua |
for i=1,28 do print(i) end | for i=1,28 do print(i) end | Correct. | Lua |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
JOIN profiles ON orders.id = profiles.id | JOIN profiles ON orders.id = profiles.id | Correct. | SQL |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
{{"id":"hello",}} | {{"id":"hello"}} | Remove trailing comma. | JSON |
arr[1] | if (length(arr) >= 1) arr[1] | Check length. | R |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
class Person {{ int item; }}; | class Person {{ public: int item; }}; | Make public. | C++ |
while item > 45
item -= 1 | while item > 45:
item -= 1 | Colon missing after while. | Python |
count = 64 | count=64 | No spaces. | Shell |
[x*x for x in arr if x > 49] | [x*x for x in arr if x > 49] | Correct list comprehension. | Python |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
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 |
[31, 70, 8 | [31, 70, 8] | Close bracket. | Ruby |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
'value' + 71 | 'value' + str(71) | Can't add int to string. | Python |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
if num = 1: | if num == 1: | Use == for comparison. | Python |
my @arr = (87,8,50); | my @arr = (87,8,50); | Correct. | Perl |
{{'status':19, 'age' 15}} | {{'status':19, 'age':15}} | Colon missing. | Python |
int[] arr = new int[5];
arr[5] = 5; | int[] arr = new int[5];
if (5 < arr.length) arr[5] = 5; | Check bounds. | Java |
let text1 = String::from("hello"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (foo = 62) {{}} | if (foo === 62) {{}} | Use === for equality. | JavaScript |
WHERE status = '61' | WHERE status = 61 | Don't quote integer. | SQL |
String y = 'world'; | String y = "world"; | Double quotes. | Java |
if [ $b = 61 ]; then | if [ "$b" = 61 ]; then | Quote variable. | Shell |
var x int | var x int | Correct. | Go |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(47); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(47, () => console.log('listening')); | Add callback. | Node.js |
DELETE FROM items WHERE age=66 | DELETE FROM items WHERE age=66; | Add semicolon. | SQL |
if b = 79 | if b == 79 | Use ==. | MATLAB |
def process():
print('hello') | def process():
print('hello') | Indent function body. | Python |
name: test
age: 23 | name: test
age: 23 | Correct. | YAML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (c = 10) {} | if (c == 10) {} | Use ==. | Dart |
let a = 25; a += 1; | let mut a = 25; a += 1; | Need mut to modify. | Rust |
<note><desc>hello</desc><age>15</age></note | <note><desc>hello</desc><age>15</age></note> | Add closing >. | XML |
values.forEach(function(x) {{ console.log(x); }}) | values.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
<person age=98> | <person age="98"> | Quote attribute. | XML |
let text = String::from("output"); let r=&text; text.push_str("!"); | let mut text = String::from("output"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
let mut data=17; let ref1=&mut data; let r2=&mut data; | let mut data=17; {{ let ref1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
yield num | yield num | Correct yield. | Python |
val result = 'result' | val result = "result" | Double quotes. | Kotlin |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
let bar = 66; let bar = 63; | let bar = 66; bar = 63; | Duplicate declaration. | JavaScript |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
values[60] | if values.indices.contains(60) {{ values[60] }} | Check index. | Swift |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
data[91] | if (data.indices.contains(91)) data[91] | Check index. | Kotlin |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
if z = 95 then
print('value')
end | if z == 95 then
print('value')
end | Use ==. | Lua |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
bar | bar() | Add parentheses. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.