wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if b > 7
puts 'message' | if b > 7
puts 'message'
end | Add 'end'. | Ruby |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
switch(z){{ case 67: break; }} | switch(z){{ case 67: break; default: break; }} | Add default case. | Java |
<input type='text' value='result'> | <input type='text' value='result' name='name'> | Add name attribute. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
result = world | result = 'world' | Quote strings. | Python |
SELECT * FROM products WHRE id=67; | SELECT * FROM products WHERE id=67; | Fix WHERE. | SQL |
const result = 12; result = 78; | let result = 12; result = 78; | Cannot reassign const. | JavaScript |
'value' + 33 | 'value' + 33.to_s | Convert int. | Ruby |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
if item = 75 then
print('data')
end | if item == 75 then
print('data')
end | Use ==. | Lua |
local b = 58 | local b = 58 | Correct. | Lua |
$items[78] = 5; | if (isset($items[78])) $items[78] = 5; | Check existence. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
[54, 81, 78 | [54, 81, 78] | Close bracket. | Ruby |
while val > 96
val -= 1 | while val > 96:
val -= 1 | Colon missing after while. | Python |
if (c = 1) {} | if (c == 1) {} | Use ==. | Dart |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
UPDATE products SET id='hello' WHERE email=91 | UPDATE products SET id='hello' WHERE email=91; | Add semicolon. | SQL |
if ($num = 38) | if ($num == 38) | Use ==. | Perl |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
render | render() | Add parentheses. | Swift |
var x = 94; | var x = 94; | Correct. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
def handle(z):
return z + 1 | def handle(z):
return z + 1 | Correct. | Python |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
fn compute() -> i32 {{ 35 }} | fn compute() -> i32 {{ 35 }} | Correct. | Rust |
["world", 18] | ["world", 18] | Correct. | JSON |
let a = 90; a += 1; | let mut a = 90; a += 1; | Need mut to modify. | Rust |
val b = 'world' | val b = "world" | Double quotes. | Kotlin |
let data = 'hello' | let data = "hello" | Double quotes. | Swift |
x := 16 | x := 16 | Correct. | Go |
let a: Int = 'hello' | let a: String = 'hello' | Fix type. | Swift |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
$data = 8; if ($data = 8) {{}} | $data = 8; if ($data == 8) {{}} | Use ==. | PHP |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
66index = 10 | index66 = 10 | Variable cannot start with digit. | Python |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:58}}; | Add missing property. | TypeScript |
a == '2' | a === 2 | Use strict equality. | JavaScript |
'58' + 23 | 58 + 23 | Avoid string coercion. | JavaScript |
[46, 41, 46 | [46, 41, 46] | Close bracket. | Python |
disp('output') | disp('output') | Correct. | MATLAB |
if val = 32 | if val == 32 | Use ==. | MATLAB |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
int foo = 'info'; | String foo = 'info'; | Type mismatch. | Dart |
if data = 67 | if data == 67 | Use ==. | Ruby |
for i=1,59 do print(i) end | for i=1,59 do print(i) end | Correct. | Lua |
<person age=68> | <person age="68"> | Quote attribute. | XML |
test | test() | Add parentheses. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let c: i32 = "test"; | let c: &str = "test"; | Type mismatch. | Rust |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
for (int i=0; i<69; i++) {{}} | for (int i=0; i<69; i++) {{}} | Correct. | Java |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(82); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(82); | Correct. | Node.js |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
arr[72] | if arr.indices.contains(72) {{ arr[72] }} | Check index. | Swift |
String bar = 'value'; | String bar = "value"; | Double quotes. | Java |
h1 {{ font-size:37px color:green; }} | h1 {{ font-size:37px; color:green; }} | Add semicolon. | CSS |
def render():
print('test') | def render():
print('test') | Indent function body. | Python |
let foo: number | null = null; foo.toFixed(62); | let foo: number | null = null; if(foo!==null) foo.toFixed(62); | Null check. | TypeScript |
my @arr = (23,88,62); | my @arr = (23,88,62); | Correct. | Perl |
if [ $bar = 41 ]; then | if [ "$bar" = 41 ]; then | Quote variable. | Shell |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
echo info test | echo 'info test' | Quote to prevent splitting. | Shell |
$items[43] | if ($items.Count -gt 43) {{ $items[43] }} | Check bounds. | PowerShell |
var count int = 'test' | var count string = 'test' | Type mismatch. | Go |
if temp > 78
print('test') | if temp > 78:
print('test') | Colon missing after if. | Python |
assert z > 96 | assert z > 96 | Correct. | Python |
{{'name':'output'}} | {{"name":"output"}} | Use double quotes. | JSON |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
yield x | yield x | Correct yield. | Python |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
print 'message' | print('message') | print needs parentheses. | Python |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
let x = 73; | let x = 73; | Correct. | JavaScript |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
{{'value':11, 'id' 34}} | {{'value':11, 'id':34}} | Colon missing. | Python |
WHERE email = '52' | WHERE email = 52 | Don't quote integer. | SQL |
let result = 61; let result = 20; | let result = 61; result = 20; | Duplicate declaration. | JavaScript |
function compute(item:string){{return item;}} compute(92); | function compute(item:string){{return item;}} compute('hello'); | Pass correct type. | TypeScript |
data.forEach(function(count) {{ console.log(count); }}) | data.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
List(36,50,84) | List(36,50,84) | Correct. | Scala |
function foo() {{ echo 'info'; }} | function foo() {{ echo 'info'; }} | Correct. | PHP |
DELETE FROM orders WHERE age=11 | DELETE FROM orders WHERE age=11; | Add semicolon. | SQL |
val item = 80; item = 53 | var item = 80; item = 53 | Use var for reassignment. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
JOIN profiles ON users.id = profiles.email | JOIN profiles ON users.id = profiles.email | Correct. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(46); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(46, () => console.log('listening')); | Add callback. | Node.js |
const index; | const index = 23; | Initialize const. | JavaScript |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.