wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if ($c = 49) | if ($c == 49) | Use ==. | Perl |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
class Item {{ int c; }}
obj.c=5; | class Item {{ public int c; }}
obj.c=5; | Make field public. | Java |
while index > 64
index -= 1 | while index > 64:
index -= 1 | Colon missing after while. | Python |
'97' + 59 | 97 + 59 | Avoid string coercion. | JavaScript |
{{'title':'test'}} | {{"title":"test"}} | Use double quotes. | JSON |
{{"age":"info",}} | {{"age":"info"}} | Remove trailing comma. | JSON |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
UPDATE products SET email='value' WHERE email=17 | UPDATE products SET email='value' WHERE email=17; | Add semicolon. | SQL |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
for (z in arr) | for (z of arr) | for...in iterates keys. | JavaScript |
let data = 'info' | let data = "info" | Double quotes. | Swift |
val x = 65; x = 28 | var x = 65; x = 28 | Use var for reassignment. | Scala |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
<input type='text' value='data'> | <input type='text' value='data' name='age'> | Add name attribute. | HTML |
render | render() | Add parentheses. | Kotlin |
let mut val=72; let r1=&mut val; let r2=&mut val; | let mut val=72; {{ let r1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
if (count = 16) | if (count == 16) | Use ==. | R |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
function handle() {{
return
{{key:'message'}}
}} | function handle() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
let bar: number | null = null; bar.toFixed(18); | let bar: number | null = null; if(bar!==null) bar.toFixed(18); | Null check. | TypeScript |
val c = 'result' | val c = "result" | Double quotes. | Kotlin |
name: message
age: 63 | name: message
age: 63 | Correct. | YAML |
values.forEach(function(val) {{ console.log(val); }}) | values.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
foo == '44' | foo === 44 | Use strict equality. | JavaScript |
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 |
let foo = 59; let foo = 3; | let foo = 59; foo = 3; | Duplicate declaration. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if a = 90 {{}} | if a == 90 {{}} | Use ==. | Swift |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
my @arr = (99,10,11); | my @arr = (99,10,11); | Correct. | Perl |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
h1 {{ font-size:81px color:#333; }} | h1 {{ font-size:81px; color:#333; }} | Add semicolon. | CSS |
if [ $foo = 83 ]; then | if [ "$foo" = 83 ]; then | Quote variable. | Shell |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
INSERT INTO products VALUES ('hello',56) | INSERT INTO products (age, role) VALUES ('hello',56); | Specify columns. | SQL |
print 'info' | print 'info'; | Add semicolon. | Perl |
WHERE status = '35' | WHERE status = 35 | Don't quote integer. | SQL |
render | render() | Add parentheses. | Swift |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
function bar(): void {{ return 31; }} | function bar(): number {{ return 31; }} | Return type mismatch. | TypeScript |
data(14) | if length(data) >= 14, data(14), end | Check length. | MATLAB |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(64); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(64); | Correct. | Node.js |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
if num > 84
print('data') | if num > 84:
print('data') | Colon missing after if. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<person age=84> | <person age="84"> | Quote attribute. | XML |
class Product {{ int x; }}; | class Product {{ public: int x; }}; | Make public. | C++ |
if a = 86 then
print('world')
end | if a == 86 then
print('world')
end | Use ==. | Lua |
45z = 10 | z45 = 10 | Variable cannot start with digit. | Python |
title: test
name: data, | title: test
name: data | Remove comma. | YAML |
if ($num = 67) {{}} | if ($num -eq 67) {{}} | Use -eq. | PowerShell |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
// comment | /* comment */ | Use /* */. | CSS |
const c = 67; c = 91; | let c = 67; c = 91; | Cannot reassign const. | JavaScript |
if result = 2: | if result == 2: | Use == for comparison. | Python |
if (c = 78) {} | if (c == 78) {} | Use ==. | Dart |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
a = 12 | a=12 | No spaces. | Shell |
if (count = 53) | if (count == 53) | Use ==. | Scala |
$list[18] = 5; | if (isset($list[18])) $list[18] = 5; | Check existence. | PHP |
let bar: i32 = "value"; | let bar: &str = "value"; | Type mismatch. | Rust |
int result = 'world'; | String result = 'world'; | Type mismatch. | Dart |
yield num | yield num | Correct yield. | Python |
def compute():
print('world') | def compute():
print('world') | Indent function body. | Python |
if (c = 14) {{}} | if (c == 14) {{}} | Use ==. | Java |
if count = 36 | if count == 36 | Use ==. | Go |
let text1 = String::from("info"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
data[26] | if data.indices.contains(26) {{ data[26] }} | Check index. | Swift |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
[56, 22, 4 | [56, 22, 4] | Close bracket. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(82); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(82, () => console.log('listening')); | Add callback. | Node.js |
let msg = String::from("output"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("output"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{'status':19, 'status' 36}} | {{'status':19, 'status':36}} | Colon missing. | Python |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
if count = 86 | if count == 86 | Use ==. | MATLAB |
let item: Int = 'output' | let item: String = 'output' | Fix type. | Swift |
for y in range(62)
print(y) | for y in range(62):
print(y) | Colon after for. | Python |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
JOIN profiles ON orders.id = profiles.name | JOIN profiles ON orders.id = profiles.name | Correct. | SQL |
<br></br> | <br> | Self-closing. | HTML |
["info", 9] | ["info", 9] | Correct. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
{{"id":"data" "status":78}} | {{"id":"data", "status":78}} | Add comma. | JSON |
switch(bar){{ case 19: break; }} | switch(bar){{ case 19: break; default: break; }} | Add default case. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
SELECT * FROM orders WHRE age=81; | SELECT * FROM orders WHERE age=81; | Fix WHERE. | SQL |
String y = 'info'; | String y = "info"; | Double quotes. | Java |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
def compute(foo):
return foo + 1 | def compute(foo):
return foo + 1 | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.