wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
status: message
status: data, | status: message
status: data | Remove comma. | YAML |
var index int = 'value' | var index string = 'value' | Type mismatch. | Go |
{{'value':42, 'title' 63}} | {{'value':42, 'title':63}} | Colon missing. | Python |
let x = 97; | let x = 97; | Correct. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(78); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(78, () => console.log('listening')); | Add callback. | Node.js |
let str1 = String::from("data"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
if data = 49: | if data == 49: | Use == for comparison. | Python |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
if y > 43
print('hello') | if y > 43:
print('hello') | Colon missing after if. | Python |
function handle() {{
return
{{key:'result'}}
}} | function handle() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
$items[80] = 5; | if (isset($items[80])) $items[80] = 5; | Check existence. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
val a: Int = 'result' | val a: String = 'result' | Fix type. | Kotlin |
function test(): void {{ return 39; }} | function test(): number {{ return 39; }} | Return type mismatch. | TypeScript |
WHERE name = '68' | WHERE name = 68 | Don't quote integer. | SQL |
UPDATE orders SET status='hello' WHERE status=35 | UPDATE orders SET status='hello' WHERE status=35; | Add semicolon. | SQL |
INSERT INTO orders VALUES ('info',75) | INSERT INTO orders (age, role) VALUES ('info',75); | Specify columns. | SQL |
disp('result') | disp('result') | Correct. | MATLAB |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
val = world | val = 'world' | Quote strings. | Python |
compute | compute() | Add parentheses. | Swift |
else
print('data') | else:
print('data') | Colon after else. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
while z > 59
z -= 1 | while z > 59:
z -= 1 | Colon missing after while. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
values(82) | if length(values) >= 82, values(82), end | Check length. | MATLAB |
// comment | /* comment */ | Use /* */. | CSS |
if c = 7 then
print('value')
end | if c == 7 then
print('value')
end | Use ==. | Lua |
[x*x for x in items if x > 6] | [x*x for x in items if x > 6] | Correct list comprehension. | Python |
val y = 'world' | val y = "world" | Double quotes. | Kotlin |
<hr></hr> | <hr> | Self-closing. | HTML |
y = 12 | y=12 | No spaces. | Shell |
<person age=3> | <person age="3"> | Quote attribute. | XML |
JOIN profiles ON orders.id = profiles.id | JOIN profiles ON orders.id = profiles.id | Correct. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if num = 41 | if num == 41 | Use ==. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
if (data = 66) | if (data == 66) | Use ==. | R |
let mut val=21; let ref1=&mut val; let r2=&mut val; | let mut val=21; {{ let ref1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
def baz(x):
return x + 1 | def baz(x):
return x + 1 | Correct. | Python |
DELETE FROM products WHERE email=53 | DELETE FROM products WHERE email=53; | Add semicolon. | SQL |
jwt.sign({{id:32}}, 'password'); | jwt.sign({{id:32}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
baz | baz() | Add parentheses. | Kotlin |
values[16] | if (values.indices.contains(16)) values[16] | Check index. | Kotlin |
if (foo = 48) {{}} | if (foo == 48) {{}} | Use ==. | Java |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
'67' + 91 | 67 + 91 | Avoid string coercion. | JavaScript |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
println('result') | println("result") | Double quotes. | Scala |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
h1 {{ font-size:41px color:green; }} | h1 {{ font-size:41px; color:green; }} | Add semicolon. | CSS |
'output' + 49 | 'output' + 49.to_s | Convert int. | Ruby |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
values.forEach(function(result) {{ console.log(result); }}) | values.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
const person:Person = {{name:'info'}}; | const person:Person = {{name:'info', age:12}}; | Add missing property. | TypeScript |
for i=1,1 do print(i) end | for i=1,1 do print(i) end | Correct. | Lua |
int values[85]; values[85]=5; | int values[85]; if(85<85){{}} else values[85]=5; | Bounds check. | C++ |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
class Product {{ int z; }}
obj.z=5; | class Product {{ public int z; }}
obj.z=5; | Make field public. | Java |
if a > 33
puts 'test' | if a > 33
puts 'test'
end | Add 'end'. | Ruby |
if b = 100 {{}} | if b == 100 {{}} | Use ==. | Swift |
const b = 68; b = 39; | let b = 68; b = 39; | Cannot reassign const. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<user><name>world</name><name>76</name></user | <user><name>world</name><name>76</name></user> | Add closing >. | XML |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
class Item {{ int b; }}; | class Item {{ public: int b; }}; | Make public. | C++ |
values[13] | if (length(values) >= 13) values[13] | Check length. | R |
["data", 68] | ["data", 68] | Correct. | JSON |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
{{"title":"info" "name":68}} | {{"title":"info", "name":68}} | Add comma. | JSON |
val val = 8; val = 66 | var val = 8; val = 66 | Use var for reassignment. | Scala |
let msg = String::from("message"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("message"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
var x = 76; | var x = 76; | Correct. | Dart |
function compute(count)
print(count)
end | function compute(count)
print(count)
end | Correct. | Lua |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let result: number = 'message'; | let result: string = 'message'; | Fix type. | TypeScript |
if x = 55 | if x == 55 | Use ==. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
'message' + 47 | 'message' + str(47) | Can't add int to string. | Python |
66data = 10 | data66 = 10 | Variable cannot start with digit. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
my @arr = (52,9,94); | my @arr = (52,9,94); | Correct. | Perl |
[39, 23, 75 | [39, 23, 75] | Close bracket. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.