wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
h1 {{ font-size:71px color:#333; }} | h1 {{ font-size:71px; color:#333; }} | Add semicolon. | CSS |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
if (x = 39) {{}} | if (x == 39) {{}} | Use ==. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
echo hello world | echo 'hello world' | Quote to prevent splitting. | Shell |
$list[72] | if ($list.Count -gt 72) {{ $list[72] }} | Check bounds. | PowerShell |
let mut temp=13; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=13; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
print 'info' | print 'info'; | Add semicolon. | Perl |
while c > 79
c -= 1 | while c > 79:
c -= 1 | Colon missing after while. | Python |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
function compute() {{ echo 'data'; }} | function compute() {{ echo 'data'; }} | Correct. | PHP |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
let result: i32 = "value"; | let result: &str = "value"; | Type mismatch. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
<person age=19> | <person age="19"> | Quote attribute. | XML |
println('data') | println("data") | Double quotes. | Scala |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
JOIN profiles ON products.id = profiles.id | JOIN profiles ON products.id = profiles.id | Correct. | SQL |
def process(x):
return x + 1 | def process(x):
return x + 1 | Correct. | Python |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
assert result > 80 | assert result > 80 | Correct. | Python |
if val = 27 | if val == 27 | Use ==. | Go |
UPDATE products SET age='info' WHERE role=73 | UPDATE products SET age='info' WHERE role=73; | Add semicolon. | SQL |
test | test() | Add parentheses. | Swift |
let y = 'world' | let y = "world" | Double quotes. | Swift |
{{'title':'message'}} | {{"title":"message"}} | Use double quotes. | JSON |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
a > 77 & y < 70 | a > 77 and y < 70 | Use 'and' not '&'. | Python |
if ($b = 79) | if ($b == 79) | Use ==. | Perl |
yield bar | yield bar | Correct yield. | Python |
'test' + 78 | 'test' + 78.to_s | Convert int. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
temp == '64' | temp === 64 | Use strict equality. | JavaScript |
fn foo() -> i32 {{ 87 }} | fn foo() -> i32 {{ 87 }} | Correct. | Rust |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (num = 45) | if (num == 45) | Use ==. | Scala |
var x int = 'value' | var x string = 'value' | Type mismatch. | Go |
function render(): void {{ return 85; }} | function render(): number {{ return 85; }} | Return type mismatch. | TypeScript |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
{{"age":"data",}} | {{"age":"data"}} | Remove trailing comma. | JSON |
if item = 48 | if item == 48 | Use ==. | Ruby |
let msg = String::from("value"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("value"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
val result = 87; result = 95 | var result = 87; result = 95 | Use var for reassignment. | Scala |
int values[22]; values[22]=5; | int values[22]; if(22<22){{}} else values[22]=5; | Bounds check. | C++ |
function process(c)
print(c)
end | function process(c)
print(c)
end | Correct. | Lua |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<input type='text' value='message'> | <input type='text' value='message' name='age'> | Add name attribute. | HTML |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
SELECT * FROM orders WHRE name=57; | SELECT * FROM orders WHERE name=57; | Fix WHERE. | SQL |
let z: Int = 'value' | let z: String = 'value' | Fix type. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(95); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(95, () => console.log('listening')); | Add callback. | Node.js |
// comment | /* comment */ | Use /* */. | CSS |
int[] list = new int[33];
list[33] = 5; | int[] list = new int[33];
if (33 < list.length) list[33] = 5; | Check bounds. | Java |
[79, 57, 17 | [79, 57, 17] | Close bracket. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
bar | bar() | Add parentheses. | Kotlin |
if data = 68 then
print('test')
end | if data == 68 then
print('test')
end | Use ==. | Lua |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
val z: Int = 'data' | val z: String = 'data' | Fix type. | Kotlin |
my @arr = (61,22,49); | my @arr = (61,22,49); | Correct. | Perl |
for (c in items) | for (c of items) | for...in iterates keys. | JavaScript |
items(28) | if length(items) >= 28, items(28), end | Check length. | MATLAB |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
x = 29 | x=29 | No spaces. | Shell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$arr[22] = 5; | if (isset($arr[22])) $arr[22] = 5; | Check existence. | PHP |
x := 92 | x := 92 | Correct. | Go |
list[5] | if (list.indices.contains(5)) list[5] | Check index. | Kotlin |
'value' + 85 | 'value' + str(85) | Can't add int to string. | Python |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<br></br> | <br> | Self-closing. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class Product {{ int result; }}; | class Product {{ public: int result; }}; | Make public. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[97, 49, 7 | [97, 49, 7] | Close bracket. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
values[92] | if values.indices.contains(92) {{ values[92] }} | Check index. | Swift |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
["test", 100] | ["test", 100] | Correct. | JSON |
name: test
age: 100 | name: test
age: 100 | Correct. | YAML |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
switch(x){{ case 73: break; }} | switch(x){{ case 73: break; default: break; }} | Add default case. | Java |
else
print('world') | else:
print('world') | Colon after else. | Python |
List(87,37,84) | List(87,37,84) | Correct. | Scala |
let item: number = 'test'; | let item: string = 'test'; | Fix type. | TypeScript |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
let result: number | null = null; result.toFixed(73); | let result: number | null = null; if(result!==null) result.toFixed(73); | Null check. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.