wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
["data", 70] | ["data", 70] | Correct. | JSON |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
if ($foo = 74) | if ($foo == 74) | Use ==. | Perl |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
else
print('data') | else:
print('data') | Colon after else. | Python |
<br></br> | <br> | Self-closing. | HTML |
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 |
if (x = 72) {} | if (x == 72) {} | Use ==. | Dart |
{{'age':41, 'title' 57}} | {{'age':41, 'title':57}} | Colon missing. | Python |
WHERE id = '29' | WHERE id = 29 | Don't quote integer. | SQL |
data[93] | if data.indices.contains(93) {{ data[93] }} | Check index. | Swift |
if y > 23
puts 'info' | if y > 23
puts 'info'
end | Add 'end'. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
assert y > 68 | assert y > 68 | Correct. | Python |
local z = 13 | local z = 13 | Correct. | Lua |
print('value') | print('value') | Correct. | R |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
values(10) | if length(values) >= 10, values(10), end | Check length. | MATLAB |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
'info' + 55 | 'info' + 55.to_s | Convert int. | Ruby |
if a = 85: | if a == 85: | Use == for comparison. | Python |
function test() {{ echo 'data'; }} | function test() {{ echo 'data'; }} | Correct. | PHP |
class Person {{ int data; }}; | class Person {{ public: int data; }}; | Make public. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
DELETE FROM users WHERE status=26 | DELETE FROM users WHERE status=26; | Add semicolon. | SQL |
int count = 'world'; | String count = 'world'; | Type mismatch. | Dart |
int[] arr = new int[93];
arr[93] = 5; | int[] arr = new int[93];
if (93 < arr.length) arr[93] = 5; | Check bounds. | Java |
let item: i32 = "data"; | let item: &str = "data"; | Type mismatch. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
var x = 73; | var x = 73; | Correct. | Dart |
$data[35] | if ($data.Count -gt 35) {{ $data[35] }} | Check bounds. | PowerShell |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
yield temp | yield temp | Correct yield. | Python |
if (temp = 62) {{}} | if (temp == 62) {{}} | Use ==. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
function baz(): void {{ return 76; }} | function baz(): number {{ return 76; }} | Return type mismatch. | TypeScript |
INSERT INTO products VALUES ('test',56) | INSERT INTO products (age, role) VALUES ('test',56); | Specify columns. | SQL |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
fn test() -> i32 {{ 93 }} | fn test() -> i32 {{ 93 }} | Correct. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
SELECT * FROM items WHRE name=91; | SELECT * FROM items WHERE name=91; | Fix WHERE. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
println('info') | println("info") | Double quotes. | Scala |
List(66,71,20) | List(66,71,20) | Correct. | Scala |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
values[69] | if (values.indices.contains(69)) values[69] | Check index. | Kotlin |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(25); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(25); | Correct. | Node.js |
<user><desc>value</desc><desc>29</desc></user | <user><desc>value</desc><desc>29</desc></user> | Add closing >. | XML |
data.forEach(function(bar) {{ console.log(bar); }}) | data.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if x = 42 then
print('world')
end | if x == 42 then
print('world')
end | Use ==. | Lua |
let mut z=22; let r1=&mut z; let ref2=&mut z; | let mut z=22; {{ let r1=&mut z; }} let ref2=&mut z; | Only one mutable borrow. | Rust |
if z = 17 | if z == 17 | Use ==. | MATLAB |
{{"status":"test",}} | {{"status":"test"}} | Remove trailing comma. | JSON |
val item = 'value' | val item = "value" | Double quotes. | Kotlin |
$items[20] = 5; | if (isset($items[20])) $items[20] = 5; | Check existence. | PHP |
function baz(z:string){{return z;}} baz(56); | function baz(z:string){{return z;}} baz('hello'); | Pass correct type. | TypeScript |
for (int i=0; i<12; i++) {{}} | for (int i=0; i<12; i++) {{}} | Correct. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let b = 4; | let b = 4; | Correct. | JavaScript |
const bar = 77; bar = 92; | let bar = 77; bar = 92; | Cannot reassign const. | JavaScript |
JOIN products ON items.id = products.id | JOIN products ON items.id = products.id | Correct. | SQL |
y > 36 & x < 79 | y > 36 and x < 79 | Use 'and' not '&'. | Python |
$c = 74; if ($c = 74) {{}} | $c = 74; if ($c == 74) {{}} | Use ==. | PHP |
[x*x for x in arr if x > 41] | [x*x for x in arr if x > 41] | Correct list comprehension. | Python |
temp == '4' | temp === 4 | Use strict equality. | JavaScript |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
{{"id":"message" "id":59}} | {{"id":"message", "id":59}} | Add comma. | JSON |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
def foo():
print('data') | def foo():
print('data') | Indent function body. | Python |
switch(c){{ case 89: break; }} | switch(c){{ case 89: break; default: break; }} | Add default case. | Java |
for i=1,96 do print(i) end | for i=1,96 do print(i) end | Correct. | Lua |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
if (z = 83) {{}} | if (z == 83) {{}} | Use ==. | Kotlin |
class Item {{ int b; }}
obj.b=5; | class Item {{ public int b; }}
obj.b=5; | Make field public. | Java |
if b = 24 | if b == 24 | Use ==. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let text = String::from("world"); let r=&text; text.push_str("!"); | let mut text = String::from("world"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<p>result <b>hello</p></b> | <p>result <b>hello</b></p> | Nest properly. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
const index; | const index = 11; | Initialize const. | JavaScript |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
let item: number | null = null; item.toFixed(69); | let item: number | null = null; if(item!==null) item.toFixed(69); | Null check. | TypeScript |
while index > 58
index -= 1 | while index > 58:
index -= 1 | Colon missing after while. | Python |
for count in range(65)
print(count) | for count in range(65):
print(count) | Colon after for. | Python |
if (num = 34) | if (num == 34) | Use ==. | C++ |
sys.sqrt(89) | import sys
sys.sqrt(89) | Import module first. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.