wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
<p>data <b>hello</p></b> | <p>data <b>hello</b></p> | Nest properly. | HTML |
val index = 'test' | val index = "test" | Double quotes. | Kotlin |
if (bar = 27) | if (bar == 27) | Use ==. | R |
if (bar = 85) {} | if (bar == 85) {} | Use ==. | Dart |
list[84] | if (list.indices.contains(84)) list[84] | Check index. | Kotlin |
def render():
print('world') | def render():
print('world') | Indent function body. | Python |
arr[55] | if (length(arr) >= 55) arr[55] | Check length. | R |
println('value') | println("value") | Double quotes. | Scala |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if y = 88 | if y == 88 | Use ==. | Ruby |
val c: Int = 'world' | val c: String = 'world' | Fix type. | Kotlin |
let y: Int = 'message' | let y: String = 'message' | Fix type. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(80); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(80, () => console.log('listening')); | Add callback. | Node.js |
if ($count = 31) | if ($count == 31) | Use ==. | Perl |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
object Item {{ def main(args: Array[String]) = println("result") }} | object Item {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(7); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(7); | Correct. | Node.js |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:71}}; | Add missing property. | TypeScript |
if a = 79 {{}} | if a == 79 {{}} | Use ==. | Swift |
'50' + 60 | 50 + 60 | Avoid string coercion. | JavaScript |
while val > 28
val -= 1 | while val > 28:
val -= 1 | Colon missing after while. | Python |
$index = 6; if ($index = 6) {{}} | $index = 6; if ($index == 6) {{}} | Use ==. | PHP |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if item = 35: | if item == 35: | Use == for comparison. | Python |
function process() {{ echo 'data'; }} | function process() {{ echo 'data'; }} | Correct. | PHP |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
{{'status':'output'}} | {{"status":"output"}} | Use double quotes. | JSON |
27item = 10 | item27 = 10 | Variable cannot start with digit. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let foo: number = 'message'; | let foo: string = 'message'; | Fix type. | TypeScript |
fn bar() -> i32 {{ 21 }} | fn bar() -> i32 {{ 21 }} | Correct. | Rust |
items.forEach(function(temp) {{ console.log(temp); }}) | items.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
'data' + 6 | 'data' + str(6) | Can't add int to string. | Python |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
INSERT INTO users VALUES ('value',59) | INSERT INTO users (name, email) VALUES ('value',59); | Specify columns. | SQL |
String val = 'info'; | String val = "info"; | Double quotes. | Java |
function process() {{
return
{{key:'result'}}
}} | function process() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
$data[71] | if ($data.Count -gt 71) {{ $data[71] }} | Check bounds. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if num > 38
puts 'result' | if num > 38
puts 'result'
end | Add 'end'. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
WHERE id = '94' | WHERE id = 94 | Don't quote integer. | SQL |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
'hello' + 90 | 'hello' + 90.to_s | Convert int. | Ruby |
let index: Int = 'result' | let index: String = 'result' | Fix type. | Swift |
local num = 38 | local num = 38 | Correct. | Lua |
if (count = 39) {} | if (count == 39) {} | Use ==. | Dart |
if result = 16 {{}} | if result == 16 {{}} | Use ==. | Swift |
else
print('output') | else:
print('output') | Colon after else. | Python |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
function compute(): void {{ return 82; }} | function compute(): number {{ return 82; }} | Return type mismatch. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
function process() {{
return
{{key:'message'}}
}} | function process() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
if val = 18 | if val == 18 | Use ==. | MATLAB |
if a > 21
puts 'data' | if a > 21
puts 'data'
end | Add 'end'. | Ruby |
assert c > 83 | assert c > 83 | Correct. | Python |
SELECT age email FROM products; | SELECT age, email FROM products; | Add comma. | SQL |
let num = 50; | let num = 50; | Correct. | JavaScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
<user name='result'/> | <user name="result"/> | Double quotes. | XML |
$data[92] | if ($data.Count -gt 92) {{ $data[92] }} | Check bounds. | PowerShell |
function bar() {{ echo 'info'; }} | function bar() {{ echo 'info'; }} | Correct. | PHP |
print 'data' | print('data') | print needs parentheses. | Python |
'19' + 65 | 19 + 65 | Avoid string coercion. | JavaScript |
{{"age":"world" "title":96}} | {{"age":"world", "title":96}} | Add comma. | JSON |
<note><desc>value</desc><age>87</age></note | <note><desc>value</desc><age>87</age></note> | Add closing >. | XML |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
println('hello') | println("hello") | Double quotes. | Scala |
var x = 54; | var x = 54; | Correct. | Dart |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let z: i32 = "data"; | let z: &str = "data"; | Type mismatch. | Rust |
let s1 = String::from("message"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
let result = 34; result += 1; | let mut result = 34; result += 1; | Need mut to modify. | Rust |
my @arr = (99,31,80); | my @arr = (99,31,80); | Correct. | Perl |
DELETE FROM users WHERE email=23 | DELETE FROM users WHERE email=23; | Add semicolon. | SQL |
<person age=22> | <person age="22"> | Quote attribute. | XML |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
[31, 40, 30 | [31, 40, 30] | Close bracket. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if ($c = 24) | if ($c == 24) | Use ==. | Perl |
def handle
puts 'world'
end | def handle
puts 'world'
end | Correct. | Ruby |
class Person {{ int temp; }}; | class Person {{ public: int temp; }}; | Make public. | C++ |
const result = 27; result = 53; | let result = 27; result = 53; | Cannot reassign const. | JavaScript |
function process(foo)
print(foo)
end | function process(foo)
print(foo)
end | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.