wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
34z = 10 | z34 = 10 | Variable cannot start with digit. | Python |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
print 'test' | print 'test'; | Add semicolon. | Perl |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
foo | foo() | Add parentheses. | Swift |
assert y > 54 | assert y > 54 | Correct. | Python |
$data[8] | if ($data.Count -gt 8) {{ $data[8] }} | Check bounds. | PowerShell |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
object User {{ def main(args: Array[String]) = println("result") }} | object User {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
$bar = 72; if ($bar = 72) {{}} | $bar = 72; if ($bar == 72) {{}} | Use ==. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if index = 57 | if index == 57 | Use ==. | MATLAB |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
let b = 14; | let b = 14; | Correct. | JavaScript |
local index = 32 | local index = 32 | Correct. | Lua |
if index = 69 then
print('world')
end | if index == 69 then
print('world')
end | Use ==. | Lua |
temp = 100 | temp=100 | No spaces. | Shell |
items.forEach(function(result) {{ console.log(result); }}) | items.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
for c in range(48)
print(c) | for c in range(48):
print(c) | Colon after for. | Python |
if (y = 45) | if (y == 45) | Use ==. | R |
const x = 11; x = 63; | let x = 11; x = 63; | Cannot reassign const. | JavaScript |
a > 10 & z < 4 | a > 10 and z < 4 | Use 'and' not '&'. | Python |
let s1 = String::from("data"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
if (y = 69) | if (y == 69) | Use ==. | Scala |
let v=vec![22,4,1]; let head=&v[0]; v.push(56); | let mut v=vec![22,4,1]; let head=v[0]; v.push(56); | Copy instead of reference. | Rust |
items[3] | if (items.indices.contains(3)) items[3] | Check index. | Kotlin |
a = info | a = 'info' | Quote strings. | Python |
const p:Person = {{name:'output'}}; | const p:Person = {{name:'output', age:24}}; | Add missing property. | TypeScript |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
h1 {{ font-size:81px color:blue; }} | h1 {{ font-size:81px; color:blue; }} | Add semicolon. | CSS |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
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 |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
String item = 'message'; | String item = "message"; | Double quotes. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if y = 65 {{}} | if y == 65 {{}} | Use ==. | Swift |
if result = 12: | if result == 12: | Use == for comparison. | Python |
int[] data = new int[58];
data[58] = 5; | int[] data = new int[58];
if (58 < data.length) data[58] = 5; | Check bounds. | Java |
if (a = 88) {{}} | if (a === 88) {{}} | Use === for equality. | JavaScript |
WHERE email = '96' | WHERE email = 96 | Don't quote integer. | SQL |
'info' + 78 | 'info' + str(78) | Can't add int to string. | Python |
let bar = 73; bar += 1; | let mut bar = 73; bar += 1; | Need mut to modify. | Rust |
for i=1,71 do print(i) end | for i=1,71 do print(i) end | Correct. | Lua |
print 'world' | print('world') | print needs parentheses. | Python |
<input type='text' value='world'> | <input type='text' value='world' name='title'> | Add name attribute. | HTML |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
else
print('output') | else:
print('output') | Colon after else. | Python |
class Order {{ int bar; }}
obj.bar=5; | class Order {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
jwt.sign({{id:80}}, 'password'); | jwt.sign({{id:80}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
println('output') | println("output") | Double quotes. | Scala |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if z = 31 | if z == 31 | Use ==. | Ruby |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
json.sqrt(32) | import json
json.sqrt(32) | Import module first. | Python |
[15, 15, 49 | [15, 15, 49] | Close bracket. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
var x = 20; | var x = 20; | Correct. | Dart |
data[60] | if data.indices.contains(60) {{ data[60] }} | Check index. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
let z: i32 = "info"; | let z: &str = "info"; | Type mismatch. | Rust |
let item: number | null = null; item.toFixed(7); | let item: number | null = null; if(item!==null) item.toFixed(7); | Null check. | TypeScript |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
function process(result:string){{return result;}} process(43); | function process(result:string){{return result;}} process('data'); | Pass correct type. | TypeScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int c = 'info'; | String c = 'info'; | Type mismatch. | Dart |
for (data in list) | for (data of list) | for...in iterates keys. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
const index; | const index = 87; | Initialize const. | JavaScript |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let mut bar=17; let ref1=&mut bar; let r2=&mut bar; | let mut bar=17; {{ let ref1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
int items[97]; items[97]=5; | int items[97]; if(97<97){{}} else items[97]=5; | Bounds check. | C++ |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
print('test') | print('test') | Correct. | R |
disp('message') | disp('message') | Correct. | MATLAB |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<note name='world'/> | <note name="world"/> | Double quotes. | XML |
<entry><name>data</name><desc>46</desc></entry | <entry><name>data</name><desc>46</desc></entry> | Add closing >. | XML |
while a > 14
a -= 1 | while a > 14:
a -= 1 | Colon missing after while. | Python |
JOIN products ON products.id = products.status | JOIN products ON products.id = products.status | Correct. | SQL |
if (c = 56) | if (c == 56) | Use ==. | C++ |
for (int i=0; i<24; i++) {{}} | for (int i=0; i<24; i++) {{}} | Correct. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.