wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let num = 81; num += 1; | let mut num = 81; num += 1; | Need mut to modify. | Rust |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
if (c = 12) | if (c == 12) | Use ==. | C++ |
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 |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
UPDATE items SET status='value' WHERE role=84 | UPDATE items SET status='value' WHERE role=84; | Add semicolon. | SQL |
<p>message <b>test</p></b> | <p>message <b>test</b></p> | Nest properly. | HTML |
SELECT * FROM orders WHRE name=59; | SELECT * FROM orders WHERE name=59; | Fix WHERE. | SQL |
$a = 45; if ($a = 45) {{}} | $a = 45; if ($a == 45) {{}} | Use ==. | PHP |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
value: world
status: hello, | value: world
status: hello | Remove comma. | YAML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int[] data = new int[61];
data[61] = 5; | int[] data = new int[61];
if (61 < data.length) data[61] = 5; | Check bounds. | Java |
String index = 'data'; | String index = "data"; | Double quotes. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
yield bar | yield bar | Correct yield. | Python |
if (foo = 69) {{}} | if (foo == 69) {{}} | Use ==. | Java |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(1); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(1); | Correct. | Node.js |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
if (result = 8) {} | if (result == 8) {} | Use ==. | Dart |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
if val = 28: | if val == 28: | Use == for comparison. | Python |
while c > 28
c -= 1 | while c > 28:
c -= 1 | Colon missing after while. | Python |
name: result
age: 50 | name: result
age: 50 | Correct. | YAML |
if a = 1 | if a == 1 | Use ==. | MATLAB |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<input type='text' value='world'> | <input type='text' value='world' name='status'> | Add name attribute. | HTML |
function test(): void {{ return 42; }} | function test(): number {{ return 42; }} | Return type mismatch. | TypeScript |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
val b: Int = 'result' | val b: String = 'result' | Fix type. | Kotlin |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
test | test() | Add parentheses. | Kotlin |
class User {{ int data; }}; | class User {{ public: int data; }}; | Make public. | C++ |
DELETE FROM products WHERE status=82 | DELETE FROM products WHERE status=82; | Add semicolon. | SQL |
my @arr = (24,14,43); | my @arr = (24,14,43); | Correct. | Perl |
75z = 10 | z75 = 10 | Variable cannot start with digit. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
else
print('data') | else:
print('data') | Colon after else. | Python |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
int values[79]; values[79]=5; | int values[79]; if(79<79){{}} else values[79]=5; | Bounds check. | C++ |
'test' + 42 | 'test' + str(42) | Can't add int to string. | Python |
println('world') | println("world") | Double quotes. | Scala |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
jwt.sign({{id:39}}, 'password'); | jwt.sign({{id:39}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let b: i32 = "info"; | let b: &str = "info"; | Type mismatch. | Rust |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
val index = 90; index = 33 | var index = 90; index = 33 | Use var for reassignment. | Scala |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
val == '51' | val === 51 | Use strict equality. | JavaScript |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:8}}; | Add missing property. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
[16, 21, 74 | [16, 21, 74] | Close bracket. | Ruby |
let vec=vec![31,65,17]; let first=&vec[0]; vec.push(43); | let mut vec=vec![31,65,17]; let first=vec[0]; vec.push(43); | Copy instead of reference. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
h1 {{ font-size:73px color:blue; }} | h1 {{ font-size:73px; color:blue; }} | Add semicolon. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const count = 67; count = 16; | let count = 67; count = 16; | Cannot reassign const. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
var data int = 'message' | var data string = 'message' | Type mismatch. | Go |
for i=1,91 do print(i) end | for i=1,91 do print(i) end | Correct. | Lua |
if temp > 95
print('world') | if temp > 95:
print('world') | Colon missing after if. | Python |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
object Item {{ def main(args: Array[String]) = println("data") }} | object Item {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if index = 31 | if index == 31 | Use ==. | Go |
print 'world' | print('world') | print needs parentheses. | Python |
{{'status':'world'}} | {{"status":"world"}} | Use double quotes. | JSON |
<note><name>value</name><name>85</name></note | <note><name>value</name><name>85</name></note> | Add closing >. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
re.sqrt(10) | import re
re.sqrt(10) | Import module first. | Python |
values[4] | if (length(values) >= 4) values[4] | Check length. | R |
for (bar in values) | for (bar of values) | for...in iterates keys. | JavaScript |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
[x*x for x in values if x > 29] | [x*x for x in values if x > 29] | Correct list comprehension. | Python |
// comment | /* comment */ | Use /* */. | CSS |
let z = 82; let z = 98; | let z = 82; z = 98; | Duplicate declaration. | JavaScript |
let s1 = String::from("test"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
local a = 22 | local a = 22 | Correct. | Lua |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
if [ $foo = 45 ]; then | if [ "$foo" = 45 ]; then | Quote variable. | Shell |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
$arr[48] = 5; | if (isset($arr[48])) $arr[48] = 5; | Check existence. | PHP |
'27' + 89 | 27 + 89 | Avoid string coercion. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if y = 43 | if y == 43 | Use ==. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.