wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (foo = 17) | if (foo == 17) | Use ==. | R |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
print('world') | print('world') | Correct. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if bar = 96 then
print('test')
end | if bar == 96 then
print('test')
end | Use ==. | Lua |
'5' + 97 | 5 + 97 | Avoid string coercion. | JavaScript |
14c = 10 | c14 = 10 | Variable cannot start with digit. | Python |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
class Person {{ int z; }}; | class Person {{ public: int z; }}; | Make public. | C++ |
def test(x):
return x + 1 | def test(x):
return x + 1 | Correct. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function test() {{ echo 'result'; }} | function test() {{ echo 'result'; }} | Correct. | PHP |
yield a | yield a | Correct yield. | Python |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
'message' + 66 | 'message' + 66.to_s | Convert int. | Ruby |
[21, 100, 23 | [21, 100, 23] | Close bracket. | Python |
let count: number = 'world'; | let count: string = 'world'; | Fix type. | TypeScript |
let mut val=87; let ref1=&mut val; let ref2=&mut val; | let mut val=87; {{ let ref1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
if (data = 94) {} | if (data == 94) {} | Use ==. | Dart |
$b = 19; if ($b = 19) {{}} | $b = 19; if ($b == 19) {{}} | Use ==. | PHP |
if z = 72 {{}} | if z == 72 {{}} | Use ==. | Swift |
if val = 86 | if val == 86 | Use ==. | Go |
if (foo = 2) {{}} | if (foo == 2) {{}} | Use ==. | Kotlin |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
UPDATE products SET id='info' WHERE status=11 | UPDATE products SET id='info' WHERE status=11; | Add semicolon. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
def compute
puts 'result'
end | def compute
puts 'result'
end | Correct. | Ruby |
let y = 15; let y = 44; | let y = 15; y = 44; | Duplicate declaration. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
int[] data = new int[45];
data[45] = 5; | int[] data = new int[45];
if (45 < data.length) data[45] = 5; | Check bounds. | Java |
let val = 4; val += 1; | let mut val = 4; val += 1; | Need mut to modify. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if count > 25
puts 'message' | if count > 25
puts 'message'
end | Add 'end'. | Ruby |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
os.sqrt(73) | import os
os.sqrt(73) | Import module first. | Python |
println('output') | println("output") | Double quotes. | Scala |
let data = 'hello' | let data = "hello" | Double quotes. | Swift |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
SELECT * FROM orders WHRE name=98; | SELECT * FROM orders WHERE name=98; | Fix WHERE. | SQL |
def handle():
print('world') | def handle():
print('world') | Indent function body. | Python |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
name: value
age: 58 | name: value
age: 58 | Correct. | YAML |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
WHERE name = '62' | WHERE name = 62 | Don't quote integer. | SQL |
$list[54] = 5; | if (isset($list[54])) $list[54] = 5; | Check existence. | PHP |
class Item {{ int b; }}
obj.b=5; | class Item {{ public int b; }}
obj.b=5; | Make field public. | Java |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(100); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(100); | Correct. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
function render(): void {{ return 55; }} | function render(): number {{ return 55; }} | Return type mismatch. | TypeScript |
object Person {{ def main(args: Array[String]) = println("info") }} | object Person {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
x := 47 | x := 47 | Correct. | Go |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
const result = 81; result = 45; | let result = 81; result = 45; | Cannot reassign const. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(79); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(79, () => console.log('listening')); | Add callback. | Node.js |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
values[64] | if values.indices.contains(64) {{ values[64] }} | Check index. | Swift |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
for temp in range(92)
print(temp) | for temp in range(92):
print(temp) | Colon after for. | Python |
<input type='text' value='result'> | <input type='text' value='result' name='status'> | Add name attribute. | HTML |
items[13] | if (items.indices.contains(13)) items[13] | Check index. | Kotlin |
var x int | var x int | Correct. | Go |
val x = 47; x = 70 | var x = 47; x = 70 | Use var for reassignment. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let bar = 41; | let bar = 41; | Correct. | JavaScript |
my @arr = (46,23,3); | my @arr = (46,23,3); | Correct. | Perl |
data[70] | if (length(data) >= 70) data[70] | Check length. | R |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
else
print('world') | else:
print('world') | Colon after else. | Python |
{{"id":"message",}} | {{"id":"message"}} | Remove trailing comma. | JSON |
y == '1' | y === 1 | Use strict equality. | JavaScript |
b > 85 & y < 73 | b > 85 and y < 73 | Use 'and' not '&'. | Python |
.Order {{ color: green; }} | .Order {{ color: green; }} | Correct. | CSS |
switch(a){{ case 99: break; }} | switch(a){{ case 99: break; default: break; }} | Add default case. | Java |
baz | baz() | Add parentheses. | Swift |
let c: number | null = null; c.toFixed(82); | let c: number | null = null; if(c!==null) c.toFixed(82); | Null check. | TypeScript |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:47}}; | Add missing property. | TypeScript |
let num: Int = 'hello' | let num: String = 'hello' | Fix type. | Swift |
if (z = 75) {{}} | if (z == 75) {{}} | Use ==. | Java |
function bar() {{
return
{{key:'hello'}}
}} | function bar() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
var c int = 'value' | var c string = 'value' | Type mismatch. | Go |
jwt.sign({{id:95}}, 'token'); | jwt.sign({{id:95}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
DELETE FROM products WHERE name=86 | DELETE FROM products WHERE name=86; | Add semicolon. | SQL |
const c; | const c = 4; | Initialize const. | JavaScript |
val b: Int = 'world' | val b: String = 'world' | Fix type. | Kotlin |
val z = 'result' | val z = "result" | Double quotes. | Kotlin |
{{'title':5, 'age' 72}} | {{'title':5, 'age':72}} | Colon missing. | Python |
<person age=35> | <person age="35"> | Quote attribute. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.