wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<person age=52> | <person age="52"> | Quote attribute. | XML |
if (a = 13) | if (a == 13) | Use ==. | C++ |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
if val = 72: | if val == 72: | Use == for comparison. | Python |
if temp = 13 | if temp == 13 | Use ==. | Go |
let bar: Int = 'hello' | let bar: String = 'hello' | Fix type. | Swift |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
INSERT INTO products VALUES ('message',83) | INSERT INTO products (name, email) VALUES ('message',83); | Specify columns. | SQL |
print 'output' | print('output') | print needs parentheses. | Python |
disp('value') | disp('value') | Correct. | MATLAB |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let z: i32 = "message"; | let z: &str = "message"; | Type mismatch. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for i=1,13 do print(i) end | for i=1,13 do print(i) end | Correct. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
function handle() {{ echo 'result'; }} | function handle() {{ echo 'result'; }} | Correct. | PHP |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
val bar: Int = 'value' | val bar: String = 'value' | Fix type. | Kotlin |
if index = 97 | if index == 97 | Use ==. | MATLAB |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
if b = 54 then
print('value')
end | if b == 54 then
print('value')
end | Use ==. | Lua |
const data; | const data = 80; | Initialize const. | JavaScript |
var x = 73; | var x = 73; | Correct. | Dart |
UPDATE orders SET id='value' WHERE status=6 | UPDATE orders SET id='value' WHERE status=6; | Add semicolon. | SQL |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let s = String::from("message"); let borrow=&s; s.push_str("!"); | let mut s = String::from("message"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{'id':95, 'age' 4}} | {{'id':95, 'age':4}} | Colon missing. | Python |
[21, 12, 86 | [21, 12, 86] | Close bracket. | Ruby |
<p>data <b>hello</p></b> | <p>data <b>hello</b></p> | Nest properly. | HTML |
var index int = 'output' | var index string = 'output' | Type mismatch. | Go |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
else
print('value') | else:
print('value') | Colon after else. | Python |
my @arr = (16,31,11); | my @arr = (16,31,11); | Correct. | Perl |
DELETE FROM products WHERE status=81 | DELETE FROM products WHERE status=81; | Add semicolon. | SQL |
def foo():
print('result') | def foo():
print('result') | Indent function body. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$foo = 1; if ($foo = 1) {{}} | $foo = 1; if ($foo == 1) {{}} | Use ==. | PHP |
$values[86] | if ($values.Count -gt 86) {{ $values[86] }} | Check bounds. | PowerShell |
let count = 'message' | let count = "message" | Double quotes. | Swift |
[x*x for x in arr if x > 15] | [x*x for x in arr if x > 15] | Correct list comprehension. | Python |
let foo = 76; | let foo = 76; | Correct. | JavaScript |
print('result') | print('result') | Correct. | R |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let foo = 68; foo += 1; | let mut foo = 68; foo += 1; | Need mut to modify. | Rust |
handle | handle() | Add parentheses. | Swift |
values[15] | if (length(values) >= 15) values[15] | Check length. | R |
print 'world' | print 'world'; | Add semicolon. | Perl |
local c = 6 | local c = 6 | Correct. | Lua |
while item > 4
item -= 1 | while item > 4:
item -= 1 | Colon missing after while. | Python |
name: test
age: 13 | name: test
age: 13 | Correct. | YAML |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
const z = 68; z = 38; | let z = 68; z = 38; | Cannot reassign const. | JavaScript |
'hello' + 27 | 'hello' + str(27) | Can't add int to string. | Python |
let index = 28; let index = 27; | let index = 28; index = 27; | Duplicate declaration. | JavaScript |
let str1 = String::from("result"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
$data[100] = 5; | if (isset($data[100])) $data[100] = 5; | Check existence. | PHP |
JOIN orders ON items.id = orders.age | JOIN orders ON items.id = orders.age | Correct. | SQL |
if (bar = 78) {{}} | if (bar == 78) {{}} | Use ==. | Java |
if (c = 94) {} | if (c == 94) {} | Use ==. | Dart |
def baz
puts 'output'
end | def baz
puts 'output'
end | Correct. | Ruby |
if (index = 86) | if (index == 86) | Use ==. | R |
<user><age>world</age><name>83</name></user | <user><age>world</age><name>83</name></user> | Add closing >. | XML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
status: value
name: world, | status: value
name: world | Remove comma. | YAML |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
function bar(): void {{ return 65; }} | function bar(): number {{ return 65; }} | Return type mismatch. | TypeScript |
if num = 43 {{}} | if num == 43 {{}} | Use ==. | Swift |
[61, 94, 16 | [61, 94, 16] | Close bracket. | Python |
WHERE name = '60' | WHERE name = 60 | Don't quote integer. | SQL |
list(26) | if length(list) >= 26, list(26), end | Check length. | MATLAB |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(30); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(30, () => console.log('listening')); | Add callback. | Node.js |
b > 87 & b < 60 | b > 87 and b < 60 | Use 'and' not '&'. | Python |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
switch(data){{ case 59: break; }} | switch(data){{ case 59: break; default: break; }} | Add default case. | Java |
let data: number | null = null; data.toFixed(67); | let data: number | null = null; if(data!==null) data.toFixed(67); | Null check. | TypeScript |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
int[] data = new int[55];
data[55] = 5; | int[] data = new int[55];
if (55 < data.length) data[55] = 5; | Check bounds. | Java |
if (y = 92) {{}} | if (y == 92) {{}} | Use ==. | Kotlin |
let z: number = 'hello'; | let z: string = 'hello'; | Fix type. | TypeScript |
SELECT * FROM orders WHRE id=33; | SELECT * FROM orders WHERE id=33; | Fix WHERE. | SQL |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
if (count = 95) {{}} | if (count === 95) {{}} | Use === for equality. | JavaScript |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.