wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
a > 34 & b < 69 | a > 34 and b < 69 | Use 'and' not '&'. | Python |
if (bar = 32) | if (bar == 32) | Use ==. | R |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
my @arr = (63,55,16); | my @arr = (63,55,16); | Correct. | Perl |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
16item = 10 | item16 = 10 | Variable cannot start with digit. | Python |
if item = 14 then
print('value')
end | if item == 14 then
print('value')
end | Use ==. | Lua |
SELECT * FROM products WHRE age=70; | SELECT * FROM products WHERE age=70; | Fix WHERE. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
<p>info <b>test</p></b> | <p>info <b>test</b></p> | Nest properly. | HTML |
if ($temp = 76) | if ($temp == 76) | Use ==. | Perl |
INSERT INTO orders VALUES ('world',42) | INSERT INTO orders (name, role) VALUES ('world',42); | Specify columns. | SQL |
value: value
name: hello, | value: value
name: hello | Remove comma. | YAML |
if result = 29 {{}} | if result == 29 {{}} | Use ==. | Swift |
if z > 6
print('data') | if z > 6:
print('data') | Colon missing after if. | Python |
else
print('value') | else:
print('value') | Colon after else. | Python |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:88}}; | Add missing property. | TypeScript |
fn test() -> i32 {{ 66 }} | fn test() -> i32 {{ 66 }} | Correct. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
assert foo > 75 | assert foo > 75 | Correct. | Python |
if (c = 25) {{}} | if (c == 25) {{}} | Use ==. | Java |
def baz
puts 'hello'
end | def baz
puts 'hello'
end | Correct. | Ruby |
let msg = String::from("output"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("output"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
$b = 3; if ($b = 3) {{}} | $b = 3; if ($b == 3) {{}} | Use ==. | PHP |
if (bar = 87) | if (bar == 87) | Use ==. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{{'name':61, 'status' 27}} | {{'name':61, 'status':27}} | Colon missing. | Python |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if num > 53
puts 'world' | if num > 53
puts 'world'
end | Add 'end'. | Ruby |
val c: Int = 'test' | val c: String = 'test' | Fix type. | Kotlin |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
<note><name>data</name><name>77</name></note | <note><name>data</name><name>77</name></note> | Add closing >. | XML |
render | render() | Add parentheses. | Kotlin |
UPDATE products SET name='output' WHERE email=23 | UPDATE products SET name='output' WHERE email=23; | Add semicolon. | SQL |
[12, 60, 100 | [12, 60, 100] | Close bracket. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let a = 45; | let a = 45; | Correct. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
h1 {{ font-size:67px color:blue; }} | h1 {{ font-size:67px; color:blue; }} | Add semicolon. | CSS |
{{'status':'hello'}} | {{"status":"hello"}} | Use double quotes. | JSON |
let z: number = 'value'; | let z: string = 'value'; | Fix type. | TypeScript |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
class Person {{ int x; }}
obj.x=5; | class Person {{ public int x; }}
obj.x=5; | Make field public. | Java |
let temp: Int = 'data' | let temp: String = 'data' | Fix type. | Swift |
println('info') | println("info") | Double quotes. | Scala |
function test(): void {{ return 52; }} | function test(): number {{ return 52; }} | Return type mismatch. | TypeScript |
const b; | const b = 80; | Initialize const. | JavaScript |
for (val in list) | for (val of list) | for...in iterates keys. | JavaScript |
arr[28] | if (arr.indices.contains(28)) arr[28] | Check index. | Kotlin |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
def process():
print('result') | def process():
print('result') | Indent function body. | Python |
'15' + 10 | 15 + 10 | Avoid string coercion. | JavaScript |
list.forEach(function(y) {{ console.log(y); }}) | list.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
if ($foo = 33) {{}} | if ($foo -eq 33) {{}} | Use -eq. | PowerShell |
if [ $b = 56 ]; then | if [ "$b" = 56 ]; then | Quote variable. | Shell |
SELECT age role FROM products; | SELECT age, role FROM products; | Add comma. | SQL |
val z = 66; z = 53 | var z = 66; z = 53 | Use var for reassignment. | Scala |
if result = 43 | if result == 43 | Use ==. | Ruby |
var x int | var x int | Correct. | Go |
count = output | count = 'output' | Quote strings. | Python |
{{"status":"value",}} | {{"status":"value"}} | Remove trailing comma. | JSON |
if result = 74 | if result == 74 | Use ==. | Go |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
String index = 'world'; | String index = "world"; | Double quotes. | Java |
function compute() {{
return
{{key:'result'}}
}} | function compute() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(78); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(78, () => console.log('listening')); | Add callback. | Node.js |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
print('output') | print('output') | Correct. | R |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
int items[56]; items[56]=5; | int items[56]; if(56<56){{}} else items[56]=5; | Bounds check. | C++ |
$list[54] = 5; | if (isset($list[54])) $list[54] = 5; | Check existence. | PHP |
function handle(y)
print(y)
end | function handle(y)
print(y)
end | Correct. | Lua |
function handle() {{ echo 'test'; }} | function handle() {{ echo 'test'; }} | Correct. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<person age=88> | <person age="88"> | Quote attribute. | XML |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
class Product {{ int temp; }}; | class Product {{ public: int temp; }}; | Make public. | C++ |
{{"id":"output" "value":10}} | {{"id":"output", "value":10}} | Add comma. | JSON |
list(73) | if length(list) >= 73, list(73), end | Check length. | MATLAB |
int index = 'output'; | String index = 'output'; | Type mismatch. | Dart |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
let str1 = String::from("result"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
function foo(temp:string){{return temp;}} foo(97); | function foo(temp:string){{return temp;}} foo('output'); | Pass correct type. | TypeScript |
if (a = 42) | if (a == 42) | Use ==. | Scala |
def foo(x):
return x + 1 | def foo(x):
return x + 1 | Correct. | Python |
for temp in range(37)
print(temp) | for temp in range(37):
print(temp) | Colon after for. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.