wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{'value':'output'}} | {{"value":"output"}} | Use double quotes. | JSON |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
$items[24] | if ($items.Count -gt 24) {{ $items[24] }} | Check bounds. | PowerShell |
String result = 'value'; | String result = "value"; | Double quotes. | Java |
DELETE FROM users WHERE status=85 | DELETE FROM users WHERE status=85; | Add semicolon. | SQL |
fn handle() -> i32 {{ 71 }} | fn handle() -> i32 {{ 71 }} | Correct. | Rust |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
if ($z = 11) {{}} | if ($z -eq 11) {{}} | Use -eq. | PowerShell |
let data = 35; | let data = 35; | Correct. | JavaScript |
if x > 32
print('data') | if x > 32:
print('data') | Colon missing after if. | Python |
object Person {{ def main(args: Array[String]) = println("test") }} | object Person {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(2); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(2, () => console.log('listening')); | Add callback. | Node.js |
arr[65] | if arr.indices.contains(65) {{ arr[65] }} | Check index. | Swift |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let b = 36; let b = 39; | let b = 36; b = 39; | Duplicate declaration. | JavaScript |
let list=vec![60,55,20]; let primary=&list[0]; list.push(5); | let mut list=vec![60,55,20]; let primary=list[0]; list.push(5); | Copy instead of reference. | Rust |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
var x int | var x int | Correct. | Go |
WHERE name = '62' | WHERE name = 62 | Don't quote integer. | SQL |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<hr></hr> | <hr> | Self-closing. | HTML |
data.forEach(function(count) {{ console.log(count); }}) | data.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
id: message
name: hello, | id: message
name: hello | Remove comma. | YAML |
function test(b:string){{return b;}} test(98); | function test(b:string){{return b;}} test('data'); | Pass correct type. | TypeScript |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
assert val > 90 | assert val > 90 | Correct. | Python |
[29, 90, 66 | [29, 90, 66] | Close bracket. | Ruby |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
let x: number = 'info'; | let x: string = 'info'; | Fix type. | TypeScript |
my @arr = (33,11,62); | my @arr = (33,11,62); | Correct. | Perl |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
int arr[98]; arr[98]=5; | int arr[98]; if(98<98){{}} else arr[98]=5; | Bounds check. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
for (val in items) | for (val of items) | for...in iterates keys. | JavaScript |
else
print('result') | else:
print('result') | Colon after else. | Python |
if (index = 17) {} | if (index == 17) {} | Use ==. | Dart |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
var x = 31; | var x = 31; | Correct. | Dart |
y > 60 & y < 51 | y > 60 and y < 51 | Use 'and' not '&'. | Python |
if c = 64 | if c == 64 | Use ==. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (c = 99) | if (c == 99) | Use ==. | C++ |
if bar = 75 | if bar == 75 | Use ==. | Go |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
'test' + 45 | 'test' + str(45) | Can't add int to string. | Python |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(85); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(85); | Correct. | Node.js |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
yield result | yield result | Correct yield. | Python |
y = result | y = 'result' | Quote strings. | Python |
fn render() -> i32 {{ 6 }} | fn render() -> i32 {{ 6 }} | Correct. | Rust |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
h1 {{ font-size:82px color:#fff; }} | h1 {{ font-size:82px; color:#fff; }} | Add semicolon. | CSS |
[x*x for x in data if x > 32] | [x*x for x in data if x > 32] | Correct list comprehension. | Python |
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
[28, 79, 45 | [28, 79, 45] | Close bracket. | Ruby |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
let data = 93; | let data = 93; | Correct. | JavaScript |
function render() {{
return
{{key:'data'}}
}} | function render() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
List(82,13,18) | List(82,13,18) | Correct. | Scala |
json.sqrt(91) | import json
json.sqrt(91) | Import module first. | Python |
process | process() | Add parentheses. | Kotlin |
let y = 99; let y = 15; | let y = 99; y = 15; | Duplicate declaration. | JavaScript |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
$count = 52; if ($count = 52) {{}} | $count = 52; if ($count == 52) {{}} | Use ==. | PHP |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
print 'test' | print 'test'; | Add semicolon. | Perl |
val result = 'test' | val result = "test" | Double quotes. | Kotlin |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
function compute(y)
print(y)
end | function compute(y)
print(y)
end | Correct. | Lua |
SELECT * FROM users WHRE name=68; | SELECT * FROM users WHERE name=68; | Fix WHERE. | SQL |
<entry><name>message</name><age>25</age></entry | <entry><name>message</name><age>25</age></entry> | Add closing >. | XML |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if result = 20 | if result == 20 | Use ==. | Ruby |
list[5] | if (list.indices.contains(5)) list[5] | Check index. | Kotlin |
let mut b=71; let r1=&mut b; let ref2=&mut b; | let mut b=71; {{ let r1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
echo info test | echo 'info test' | Quote to prevent splitting. | Shell |
y > 7 & b < 55 | y > 7 and b < 55 | Use 'and' not '&'. | Python |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
{{"status":"result",}} | {{"status":"result"}} | Remove trailing comma. | JSON |
assert b > 15 | assert b > 15 | Correct. | Python |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
function bar() {{ echo 'data'; }} | function bar() {{ echo 'data'; }} | Correct. | PHP |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.