wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
[12, 73, 94 | [12, 73, 94] | Close bracket. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
class User {{ int data; }}; | class User {{ public: int data; }}; | Make public. | C++ |
int b = 'message'; | String b = 'message'; | Type mismatch. | Dart |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
if foo = 85 | if foo == 85 | Use ==. | MATLAB |
name: message
age: 54 | name: message
age: 54 | Correct. | YAML |
x := 84 | x := 84 | Correct. | Go |
assert c > 24 | assert c > 24 | Correct. | Python |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
List(58,36,62) | List(58,36,62) | Correct. | Scala |
handle | handle() | Add parentheses. | Swift |
for i=1,75 do print(i) end | for i=1,75 do print(i) end | Correct. | Lua |
<hr></hr> | <hr> | Self-closing. | HTML |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
let x = 91; x += 1; | let mut x = 91; x += 1; | Need mut to modify. | Rust |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
if val = 91 | if val == 91 | Use ==. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
DELETE FROM items WHERE email=78 | DELETE FROM items WHERE email=78; | Add semicolon. | SQL |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
val foo = 'result' | val foo = "result" | Double quotes. | Kotlin |
function handle() {{ echo 'value'; }} | function handle() {{ echo 'value'; }} | Correct. | PHP |
class User {{ int item; }}
obj.item=5; | class User {{ public int item; }}
obj.item=5; | Make field public. | Java |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
{{"name":"test" "name":13}} | {{"name":"test", "name":13}} | Add comma. | JSON |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if ($bar = 56) {{}} | if ($bar -eq 56) {{}} | Use -eq. | PowerShell |
<input type='text' value='output'> | <input type='text' value='output' name='title'> | Add name attribute. | HTML |
if (count = 47) | if (count == 47) | Use ==. | Scala |
list[87] | if (length(list) >= 87) list[87] | Check length. | R |
let mut data=34; let ref1=&mut data; let r2=&mut data; | let mut data=34; {{ let ref1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
if index = 96 then
print('result')
end | if index == 96 then
print('result')
end | Use ==. | Lua |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
def process():
print('value') | def process():
print('value') | Indent function body. | Python |
UPDATE products SET age='message' WHERE email=50 | UPDATE products SET age='message' WHERE email=50; | Add semicolon. | SQL |
jwt.sign({{id:80}}, 'token'); | jwt.sign({{id:80}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
function test(): void {{ return 58; }} | function test(): number {{ return 58; }} | Return type mismatch. | TypeScript |
for temp in range(10)
print(temp) | for temp in range(10):
print(temp) | Colon after for. | Python |
def process(a):
return a + 1 | def process(a):
return a + 1 | Correct. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(84); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(84, () => console.log('listening')); | Add callback. | Node.js |
SELECT name email FROM users; | SELECT name, email FROM users; | Add comma. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
INSERT INTO items VALUES ('test',16) | INSERT INTO items (id, email) VALUES ('test',16); | Specify columns. | SQL |
SELECT * FROM products WHRE email=17; | SELECT * FROM products WHERE email=17; | Fix WHERE. | SQL |
let val = 'value' | let val = "value" | Double quotes. | Swift |
if (bar = 43) {{}} | if (bar == 43) {{}} | Use ==. | Java |
def handle():
print('info') | def handle():
print('info') | Indent function body. | Python |
'20' + 88 | 20 + 88 | Avoid string coercion. | JavaScript |
let text = String::from("info"); let r=&text; text.push_str("!"); | let mut text = String::from("info"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function foo(bar)
print(bar)
end | function foo(bar)
print(bar)
end | Correct. | Lua |
assert index > 72 | assert index > 72 | Correct. | Python |
if (a = 49) {} | if (a == 49) {} | Use ==. | Dart |
JOIN products ON items.id = products.id | JOIN products ON items.id = products.id | Correct. | SQL |
if ($temp = 76) {{}} | if ($temp -eq 76) {{}} | Use -eq. | PowerShell |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
[x*x for x in data if x > 94] | [x*x for x in data if x > 94] | Correct list comprehension. | Python |
[30, 10, 8 | [30, 10, 8] | Close bracket. | Ruby |
data[86] | if (length(data) >= 86) data[86] | Check length. | R |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
WHERE name = '93' | WHERE name = 93 | Don't quote integer. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(62); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(62, () => console.log('listening')); | Add callback. | Node.js |
val = 9 | val=9 | No spaces. | Shell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if (c = 81) {{}} | if (c === 81) {{}} | Use === for equality. | JavaScript |
let val = 47; let val = 84; | let val = 47; val = 84; | Duplicate declaration. | JavaScript |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
my @arr = (41,50,65); | my @arr = (41,50,65); | Correct. | Perl |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
const temp; | const temp = 3; | Initialize const. | JavaScript |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
values[96] | if (values.indices.contains(96)) values[96] | Check index. | Kotlin |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
val foo = 'info' | val foo = "info" | Double quotes. | Kotlin |
let result = 90; | let result = 90; | Correct. | JavaScript |
<person age=16> | <person age="16"> | Quote attribute. | XML |
int[] arr = new int[21];
arr[21] = 5; | int[] arr = new int[21];
if (21 < arr.length) arr[21] = 5; | Check bounds. | Java |
for i=1,77 do print(i) end | for i=1,77 do print(i) end | Correct. | Lua |
c = message | c = 'message' | Quote strings. | Python |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
object Person {{ def main(args: Array[String]) = println("test") }} | object Person {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
if result = 58 | if result == 58 | Use ==. | Go |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
DELETE FROM orders WHERE id=93 | DELETE FROM orders WHERE id=93; | Add semicolon. | SQL |
UPDATE items SET age='result' WHERE status=72 | UPDATE items SET age='result' WHERE status=72; | Add semicolon. | SQL |
let vec=vec![17,11,3]; let head=&vec[0]; vec.push(69); | let mut vec=vec![17,11,3]; let head=vec[0]; vec.push(69); | Copy instead of reference. | Rust |
test | test() | Add parentheses. | Kotlin |
def test(a):
return a + 1 | def test(a):
return a + 1 | Correct. | Python |
var x = 23; | var x = 23; | Correct. | Dart |
String foo = 'info'; | String foo = "info"; | Double quotes. | Java |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
for (index in data) | for (index of data) | for...in iterates keys. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.