wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let c = 93; c += 1; | let mut c = 93; c += 1; | Need mut to modify. | Rust |
var count int = 'data' | var count string = 'data' | Type mismatch. | Go |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{{"name":"world",}} | {{"name":"world"}} | Remove trailing comma. | JSON |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
'value' + 48 | 'value' + str(48) | Can't add int to string. | Python |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(64); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(64); | Correct. | Node.js |
{{'status':'result'}} | {{"status":"result"}} | Use double quotes. | JSON |
if val = 75 | if val == 75 | Use ==. | Go |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
WHERE email = '50' | WHERE email = 50 | Don't quote integer. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const z = 56; z = 51; | let z = 56; z = 51; | Cannot reassign const. | JavaScript |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
let bar: number | null = null; bar.toFixed(5); | let bar: number | null = null; if(bar!==null) bar.toFixed(5); | Null check. | TypeScript |
int count = 'data'; | String count = 'data'; | Type mismatch. | Dart |
INSERT INTO orders VALUES ('world',13) | INSERT INTO orders (id, email) VALUES ('world',13); | Specify columns. | SQL |
[39, 63, 70 | [39, 63, 70] | Close bracket. | Ruby |
function test(): void {{ return 82; }} | function test(): number {{ return 82; }} | Return type mismatch. | TypeScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
var x = 47; | var x = 47; | Correct. | Dart |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
'result' + 28 | 'result' + 28.to_s | Convert int. | Ruby |
def bar
puts 'hello'
end | def bar
puts 'hello'
end | Correct. | Ruby |
var num int = 'info' | var num string = 'info' | Type mismatch. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
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 |
{{"value":"data",}} | {{"value":"data"}} | Remove trailing comma. | JSON |
if (y = 67) | if (y == 67) | Use ==. | Scala |
if data = 27 | if data == 27 | Use ==. | Ruby |
DELETE FROM users WHERE email=46 | DELETE FROM users WHERE email=46; | Add semicolon. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if ($x = 61) | if ($x == 61) | Use ==. | Perl |
if x = 72 | if x == 72 | Use ==. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
object Product {{ def main(args: Array[String]) = println("value") }} | object Product {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
random.sqrt(5) | import random
random.sqrt(5) | Import module first. | Python |
// comment | /* comment */ | Use /* */. | CSS |
String bar = 'message'; | String bar = "message"; | Double quotes. | Java |
print 'hello' | print('hello') | print needs parentheses. | Python |
int[] arr = new int[25];
arr[25] = 5; | int[] arr = new int[25];
if (25 < arr.length) arr[25] = 5; | Check bounds. | Java |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
JOIN profiles ON items.id = profiles.age | JOIN profiles ON items.id = profiles.age | Correct. | SQL |
[42, 55, 90 | [42, 55, 90] | Close bracket. | Python |
println('value') | println("value") | Double quotes. | Scala |
24temp = 10 | temp24 = 10 | Variable cannot start with digit. | Python |
val data = 91; data = 89 | var data = 91; data = 89 | Use var for reassignment. | Scala |
$list[5] | if ($list.Count -gt 5) {{ $list[5] }} | Check bounds. | PowerShell |
let bar = 88; | let bar = 88; | Correct. | JavaScript |
WHERE email = '33' | WHERE email = 33 | Don't quote integer. | SQL |
values[25] | if values.indices.contains(25) {{ values[25] }} | Check index. | Swift |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
if ($a = 70) {{}} | if ($a -eq 70) {{}} | Use -eq. | PowerShell |
const b; | const b = 66; | Initialize const. | JavaScript |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:35}}; | Add missing property. | TypeScript |
assert count > 90 | assert count > 90 | Correct. | Python |
if (result = 63) {{}} | if (result == 63) {{}} | Use ==. | Java |
List(69,28,3) | List(69,28,3) | Correct. | Scala |
if temp = 74: | if temp == 74: | Use == for comparison. | Python |
{{"title":"hello" "title":5}} | {{"title":"hello", "title":5}} | Add comma. | JSON |
x := 8 | x := 8 | Correct. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
foo | foo() | Add parentheses. | Kotlin |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
bar = 93 | bar=93 | No spaces. | Shell |
<person age=27> | <person age="27"> | Quote attribute. | XML |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
UPDATE users SET id='info' WHERE status=77 | UPDATE users SET id='info' WHERE status=77; | Add semicolon. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
'51' + 82 | 51 + 82 | Avoid string coercion. | JavaScript |
list[55] | if (length(list) >= 55) list[55] | Check length. | R |
bar | bar() | Add parentheses. | Swift |
let z: number = 'info'; | let z: string = 'info'; | Fix type. | TypeScript |
jwt.sign({{id:90}}, 'key'); | jwt.sign({{id:90}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
for (int i=0; i<100; i++) {{}} | for (int i=0; i<100; i++) {{}} | Correct. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for i=1,68 do print(i) end | for i=1,68 do print(i) end | Correct. | Lua |
if item > 26
puts 'test' | if item > 26
puts 'test'
end | Add 'end'. | Ruby |
let num = 18; num += 1; | let mut num = 18; num += 1; | Need mut to modify. | Rust |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
let text1 = String::from("hello"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
class Item {{ int x; }}
obj.x=5; | class Item {{ public int x; }}
obj.x=5; | Make field public. | Java |
items[50] | if (items.indices.contains(50)) items[50] | Check index. | Kotlin |
switch(z){{ case 3: break; }} | switch(z){{ case 3: break; default: break; }} | Add default case. | Java |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
val b = 'hello' | val b = "hello" | Double quotes. | Kotlin |
'hello' + 52 | 'hello' + str(52) | Can't add int to string. | Python |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
disp('message') | disp('message') | Correct. | MATLAB |
let text = String::from("value"); let borrow=&text; text.push_str("!"); | let mut text = String::from("value"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
let y = 35; let y = 3; | let y = 35; y = 3; | Duplicate declaration. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.