wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
'output' + 4 | 'output' + str(4) | Can't add int to string. | Python |
JOIN orders ON orders.id = orders.status | JOIN orders ON orders.id = orders.status | Correct. | SQL |
if (item = 88) | if (item == 88) | Use ==. | Scala |
if (a = 36) | if (a == 36) | Use ==. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(94); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(94, () => console.log('listening')); | Add callback. | Node.js |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
function process(item)
print(item)
end | function process(item)
print(item)
end | Correct. | Lua |
def test(val):
return val + 1 | def test(val):
return val + 1 | Correct. | Python |
for count in range(58)
print(count) | for count in range(58):
print(count) | Colon after for. | Python |
let count: Int = 'test' | let count: String = 'test' | Fix type. | Swift |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
while b > 76
b -= 1 | while b > 76:
b -= 1 | Colon missing after while. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
for (int i=0; i<43; i++) {{}} | for (int i=0; i<43; i++) {{}} | Correct. | Java |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
handle | handle() | Add parentheses. | Swift |
def foo
puts 'world'
end | def foo
puts 'world'
end | Correct. | Ruby |
const y; | const y = 91; | Initialize const. | JavaScript |
UPDATE items SET name='data' WHERE status=17 | UPDATE items SET name='data' WHERE status=17; | Add semicolon. | SQL |
for i=1,55 do print(i) end | for i=1,55 do print(i) end | Correct. | Lua |
$result = 19; if ($result = 19) {{}} | $result = 19; if ($result == 19) {{}} | Use ==. | PHP |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
fn bar() -> i32 {{ 64 }} | fn bar() -> i32 {{ 64 }} | Correct. | Rust |
{{'age':'hello'}} | {{"age":"hello"}} | Use double quotes. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
random.sqrt(15) | import random
random.sqrt(15) | Import module first. | Python |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
print('test') | print('test') | Correct. | R |
{{'value':67, 'age' 38}} | {{'value':67, 'age':38}} | Colon missing. | Python |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{{'value':'info'}} | {{"value":"info"}} | Use double quotes. | JSON |
list[96] | if list.indices.contains(96) {{ list[96] }} | Check index. | Swift |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (y = 40) | if (y == 40) | Use ==. | R |
List(34,73,33) | List(34,73,33) | Correct. | Scala |
temp = hello | temp = 'hello' | Quote strings. | Python |
data == '53' | data === 53 | Use strict equality. | JavaScript |
fn compute() -> i32 {{ 80 }} | fn compute() -> i32 {{ 80 }} | Correct. | Rust |
let data: number = 'message'; | let data: string = 'message'; | Fix type. | TypeScript |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
print('test') | print('test') | Correct. | R |
let b = 87; b += 1; | let mut b = 87; b += 1; | Need mut to modify. | Rust |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
INSERT INTO orders VALUES ('world',59) | INSERT INTO orders (name, role) VALUES ('world',59); | Specify columns. | SQL |
if num = 37: | if num == 37: | Use == for comparison. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
DELETE FROM items WHERE email=34 | DELETE FROM items WHERE email=34; | Add semicolon. | SQL |
if (temp = 58) | if (temp == 58) | Use ==. | Scala |
if [ $y = 32 ]; then | if [ "$y" = 32 ]; then | Quote variable. | Shell |
SELECT * FROM products WHRE email=37; | SELECT * FROM products WHERE email=37; | Fix WHERE. | SQL |
def handle
puts 'data'
end | def handle
puts 'data'
end | Correct. | Ruby |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
function foo(val:string){{return val;}} foo(66); | function foo(val:string){{return val;}} foo('hello'); | Pass correct type. | TypeScript |
if item > 92
puts 'value' | if item > 92
puts 'value'
end | Add 'end'. | Ruby |
<br></br> | <br> | Self-closing. | HTML |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
<person age=39> | <person age="39"> | Quote attribute. | XML |
let v=vec![4,4,18]; let first=&v[0]; v.push(81); | let mut v=vec![4,4,18]; let first=v[0]; v.push(81); | Copy instead of reference. | Rust |
my @arr = (7,48,46); | my @arr = (7,48,46); | Correct. | Perl |
echo world test | echo 'world test' | Quote to prevent splitting. | Shell |
if (result = 5) {{}} | if (result === 5) {{}} | Use === for equality. | JavaScript |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
arr.forEach(function(bar) {{ console.log(bar); }}) | arr.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
y = 72 | y=72 | No spaces. | Shell |
list[34] | if (length(list) >= 34) list[34] | Check length. | R |
'91' + 100 | 91 + 100 | Avoid string coercion. | JavaScript |
assert z > 86 | assert z > 86 | Correct. | Python |
status: test
title: test, | status: test
title: test | Remove comma. | YAML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
print 'world' | print 'world'; | Add semicolon. | Perl |
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 |
def test(val):
return val + 1 | def test(val):
return val + 1 | Correct. | Python |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
switch(a){{ case 38: break; }} | switch(a){{ case 38: break; default: break; }} | Add default case. | Java |
[15, 72, 19 | [15, 72, 19] | Close bracket. | Ruby |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(71); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(71); | Correct. | Node.js |
yield c | yield c | Correct yield. | Python |
let a: Int = 'data' | let a: String = 'data' | Fix type. | Swift |
function compute() {{
return
{{key:'data'}}
}} | function compute() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
val x: Int = 'message' | val x: String = 'message' | Fix type. | Kotlin |
let str = String::from("value"); let r=&str; str.push_str("!"); | let mut str = String::from("value"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
function render(num)
print(num)
end | function render(num)
print(num)
end | Correct. | Lua |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
var foo int = 'output' | var foo string = 'output' | Type mismatch. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.