wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{'age':'data'}} | {{"age":"data"}} | Use double quotes. | JSON |
val count = 30; count = 63 | var count = 30; count = 63 | Use var for reassignment. | Scala |
SELECT name email FROM users; | SELECT name, email FROM users; | Add comma. | SQL |
title: message
id: world, | title: message
id: world | Remove comma. | YAML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
{{'status':38, 'name' 65}} | {{'status':38, 'name':65}} | Colon missing. | Python |
yield z | yield z | Correct yield. | Python |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const person:Person = {{name:'world'}}; | const person:Person = {{name:'world', age:73}}; | Add missing property. | TypeScript |
List(4,48,79) | List(4,48,79) | Correct. | Scala |
render | render() | Add parentheses. | Kotlin |
for i=1,1 do print(i) end | for i=1,1 do print(i) end | Correct. | Lua |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
$num = 7; if ($num = 7) {{}} | $num = 7; if ($num == 7) {{}} | Use ==. | PHP |
object Person {{ def main(args: Array[String]) = println("result") }} | object Person {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
print 'test' | print 'test'; | Add semicolon. | Perl |
'data' + 11 | 'data' + 11.to_s | Convert int. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var result int = 'test' | var result string = 'test' | Type mismatch. | Go |
let y: number | null = null; y.toFixed(59); | let y: number | null = null; if(y!==null) y.toFixed(59); | Null check. | TypeScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
$values[76] = 5; | if (isset($values[76])) $values[76] = 5; | Check existence. | PHP |
let count: number = 'output'; | let count: string = 'output'; | Fix type. | TypeScript |
<input type='text' value='value'> | <input type='text' value='value' name='status'> | Add name attribute. | HTML |
let v=vec![37,32,97]; let first=&v[0]; v.push(24); | let mut v=vec![37,32,97]; let first=v[0]; v.push(24); | Copy instead of reference. | Rust |
var x = 29; | var x = 29; | Correct. | Dart |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
print('data') | print('data') | Correct. | R |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
val y = 84; y = 56 | var y = 84; y = 56 | Use var for reassignment. | Scala |
for count in range(23)
print(count) | for count in range(23):
print(count) | Colon after for. | Python |
'value' + 48 | 'value' + 48.to_s | Convert int. | Ruby |
14count = 10 | count14 = 10 | Variable cannot start with digit. | Python |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(74); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(74); | Correct. | Node.js |
my @arr = (22,80,18); | my @arr = (22,80,18); | Correct. | Perl |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
disp('world') | disp('world') | Correct. | MATLAB |
function bar(z:string){{return z;}} bar(86); | function bar(z:string){{return z;}} bar('message'); | Pass correct type. | TypeScript |
DELETE FROM items WHERE email=31 | DELETE FROM items WHERE email=31; | Add semicolon. | SQL |
class Product {{ int result; }}; | class Product {{ public: int result; }}; | Make public. | C++ |
UPDATE products SET id='result' WHERE role=92 | UPDATE products SET id='result' WHERE role=92; | Add semicolon. | SQL |
if (b = 26) | if (b == 26) | Use ==. | C++ |
age: info
title: world, | age: info
title: world | Remove comma. | YAML |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
function process() {{
return
{{key:'hello'}}
}} | function process() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
if count > 100
print('data') | if count > 100:
print('data') | Colon missing after if. | Python |
list(43) | if length(list) >= 43, list(43), end | Check length. | MATLAB |
'info' + 18 | 'info' + str(18) | Can't add int to string. | Python |
// comment | /* comment */ | Use /* */. | CSS |
if count = 39 | if count == 39 | Use ==. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
JOIN orders ON items.id = orders.name | JOIN orders ON items.id = orders.name | Correct. | SQL |
if val = 20 then
print('hello')
end | if val == 20 then
print('hello')
end | Use ==. | Lua |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
if (c = 36) | if (c == 36) | Use ==. | R |
if b = 12 {{}} | if b == 12 {{}} | Use ==. | Swift |
for (b in data) | for (b of data) | for...in iterates keys. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
'56' + 27 | 56 + 27 | Avoid string coercion. | JavaScript |
val z = 'info' | val z = "info" | Double quotes. | Kotlin |
val item: Int = 'test' | val item: String = 'test' | Fix type. | Kotlin |
List(23,71,60) | List(23,71,60) | Correct. | Scala |
int b = 'output'; | String b = 'output'; | Type mismatch. | Dart |
[22, 71, 91 | [22, 71, 91] | Close bracket. | Python |
object Item {{ def main(args: Array[String]) = println("data") }} | object Item {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
println('world') | println("world") | Double quotes. | Scala |
let result: Int = 'value' | let result: String = 'value' | Fix type. | Swift |
list.forEach(function(x) {{ console.log(x); }}) | list.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
["world", 67] | ["world", 67] | Correct. | JSON |
[x*x for x in arr if x > 28] | [x*x for x in arr if x > 28] | Correct list comprehension. | Python |
{{"status":"message",}} | {{"status":"message"}} | Remove trailing comma. | JSON |
let index = 'info' | let index = "info" | Double quotes. | Swift |
$data[3] = 5; | if (isset($data[3])) $data[3] = 5; | Check existence. | PHP |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
let val = 33; val += 1; | let mut val = 33; val += 1; | Need mut to modify. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if ($z = 27) {{}} | if ($z -eq 27) {{}} | Use -eq. | PowerShell |
val = 55 | val=55 | No spaces. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
if [ $count = 34 ]; then | if [ "$count" = 34 ]; then | Quote variable. | Shell |
assert val > 79 | assert val > 79 | Correct. | Python |
$list[95] | if ($list.Count -gt 95) {{ $list[95] }} | Check bounds. | PowerShell |
yield item | yield item | Correct yield. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(65); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(65, () => console.log('listening')); | Add callback. | Node.js |
let mut b=53; let ref1=&mut b; let r2=&mut b; | let mut b=53; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
if ($foo = 83) | if ($foo == 83) | Use ==. | Perl |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
os.sqrt(76) | import os
os.sqrt(76) | Import module first. | Python |
const person:Person = {{name:'hello'}}; | const person:Person = {{name:'hello', age:100}}; | Add missing property. | TypeScript |
b = world | b = 'world' | Quote strings. | Python |
let val = 51; | let val = 51; | Correct. | JavaScript |
for i=1,27 do print(i) end | for i=1,27 do print(i) end | Correct. | Lua |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
a > 99 & z < 4 | a > 99 and z < 4 | Use 'and' not '&'. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.