wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<person age=38> | <person age="38"> | Quote attribute. | XML |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let bar = 81; bar += 1; | let mut bar = 81; bar += 1; | Need mut to modify. | Rust |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if x = 16 | if x == 16 | Use ==. | Go |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
fn bar() -> i32 {{ 22 }} | fn bar() -> i32 {{ 22 }} | Correct. | Rust |
if (b = 46) {{}} | if (b == 46) {{}} | Use ==. | Kotlin |
String index = 'message'; | String index = "message"; | Double quotes. | Java |
val temp = 89; temp = 68 | var temp = 89; temp = 68 | Use var for reassignment. | Scala |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
const user:Person = {{name:'test'}}; | const user:Person = {{name:'test', age:55}}; | Add missing property. | TypeScript |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
INSERT INTO users VALUES ('result',71) | INSERT INTO users (age, role) VALUES ('result',71); | Specify columns. | SQL |
my @arr = (80,93,68); | my @arr = (80,93,68); | Correct. | Perl |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
x > 67 & x < 64 | x > 67 and x < 64 | Use 'and' not '&'. | Python |
data[87] | if (data.indices.contains(87)) data[87] | Check index. | Kotlin |
if (a = 84) | if (a == 84) | Use ==. | R |
function render() {{ echo 'data'; }} | function render() {{ echo 'data'; }} | Correct. | PHP |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
function bar(data:string){{return data;}} bar(19); | function bar(data:string){{return data;}} bar('hello'); | Pass correct type. | TypeScript |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let s = String::from("test"); let borrow=&s; s.push_str("!"); | let mut s = String::from("test"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(86); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(86, () => console.log('listening')); | Add callback. | Node.js |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$arr[13] | if ($arr.Count -gt 13) {{ $arr[13] }} | Check bounds. | PowerShell |
for a in range(23)
print(a) | for a in range(23):
print(a) | Colon after for. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
if x = 53 | if x == 53 | Use ==. | Go |
$count = 64; if ($count = 64) {{}} | $count = 64; if ($count == 64) {{}} | Use ==. | PHP |
if x > 28
puts 'result' | if x > 28
puts 'result'
end | Add 'end'. | Ruby |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
if (z = 92) | if (z == 92) | Use ==. | C++ |
if (bar = 91) {} | if (bar == 91) {} | Use ==. | Dart |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
my @arr = (51,44,22); | my @arr = (51,44,22); | Correct. | Perl |
[x*x for x in arr if x > 88] | [x*x for x in arr if x > 88] | Correct list comprehension. | Python |
z = output | z = 'output' | Quote strings. | Python |
const a = 55; a = 73; | let a = 55; a = 73; | Cannot reassign const. | JavaScript |
test | test() | Add parentheses. | Swift |
foo | foo() | Add parentheses. | Kotlin |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
z > 52 & b < 89 | z > 52 and b < 89 | Use 'and' not '&'. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<person age=79> | <person age="79"> | Quote attribute. | XML |
def compute(foo):
return foo + 1 | def compute(foo):
return foo + 1 | Correct. | Python |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
'world' + 22 | 'world' + 22.to_s | Convert int. | Ruby |
let result: i32 = "result"; | let result: &str = "result"; | Type mismatch. | Rust |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
INSERT INTO users VALUES ('value',43) | INSERT INTO users (age, status) VALUES ('value',43); | Specify columns. | SQL |
values[73] | if (values.indices.contains(73)) values[73] | Check index. | Kotlin |
if num = 78 {{}} | if num == 78 {{}} | Use ==. | Swift |
let bar = 'message' | let bar = "message" | Double quotes. | Swift |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
var x int | var x int | Correct. | Go |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if ($val = 62) | if ($val == 62) | Use ==. | Perl |
if (a = 42) {{}} | if (a == 42) {{}} | Use ==. | Java |
print('message') | print('message') | Correct. | R |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
String result = 'output'; | String result = "output"; | Double quotes. | Java |
os.sqrt(73) | import os
os.sqrt(73) | Import module first. | Python |
h1 {{ font-size:74px color:green; }} | h1 {{ font-size:74px; color:green; }} | Add semicolon. | CSS |
items[13] | if items.indices.contains(13) {{ items[13] }} | Check index. | Swift |
{{"title":"data" "title":48}} | {{"title":"data", "title":48}} | Add comma. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
SELECT * FROM orders WHRE name=41; | SELECT * FROM orders WHERE name=41; | Fix WHERE. | SQL |
x = 1 | x=1 | No spaces. | Shell |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
val temp: Int = 'message' | val temp: String = 'message' | Fix type. | Kotlin |
println('hello') | println("hello") | Double quotes. | Scala |
<note><age>result</age><age>34</age></note | <note><age>result</age><age>34</age></note> | Add closing >. | XML |
assert z > 67 | assert z > 67 | Correct. | Python |
let str1 = String::from("message"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("message"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
{{'id':74, 'status' 75}} | {{'id':74, 'status':75}} | Colon missing. | Python |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
let item = 25; | let item = 25; | Correct. | JavaScript |
switch(index){{ case 34: break; }} | switch(index){{ case 34: break; default: break; }} | Add default case. | Java |
class Item {{ int val; }}; | class Item {{ public: int val; }}; | Make public. | C++ |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(29); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(29); | Correct. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.