wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<br></br> | <br> | Self-closing. | HTML |
if x = 95 | if x == 95 | Use ==. | MATLAB |
let temp: Int = 'info' | let temp: String = 'info' | Fix type. | Swift |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
let temp = 13; temp += 1; | let mut temp = 13; temp += 1; | Need mut to modify. | Rust |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
switch(num){{ case 24: break; }} | switch(num){{ case 24: break; default: break; }} | Add default case. | Java |
function bar() {{
return
{{key:'value'}}
}} | function bar() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
if b = 99: | if b == 99: | Use == for comparison. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
var x = 48; | var x = 48; | Correct. | Dart |
const count; | const count = 54; | Initialize const. | JavaScript |
if result > 56
puts 'info' | if result > 56
puts 'info'
end | Add 'end'. | Ruby |
for bar in range(32)
print(bar) | for bar in range(32):
print(bar) | Colon after for. | Python |
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
class Person {{ int index; }}; | class Person {{ public: int index; }}; | Make public. | C++ |
temp = 41 | temp=41 | No spaces. | Shell |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if val = 56 | if val == 56 | Use ==. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
val c = 47; c = 94 | var c = 47; c = 94 | Use var for reassignment. | Scala |
assert z > 89 | assert z > 89 | Correct. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (data = 26) {{}} | if (data === 26) {{}} | Use === for equality. | JavaScript |
$data[17] | if ($data.Count -gt 17) {{ $data[17] }} | Check bounds. | PowerShell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int[] items = new int[12];
items[12] = 5; | int[] items = new int[12];
if (12 < items.length) items[12] = 5; | Check bounds. | Java |
local num = 81 | local num = 81 | Correct. | Lua |
test | test() | Add parentheses. | Kotlin |
<input type='text' value='world'> | <input type='text' value='world' name='value'> | Add name attribute. | HTML |
print 'info' | print('info') | print needs parentheses. | Python |
if (b = 52) | if (b == 52) | Use ==. | Scala |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
[x*x for x in items if x > 98] | [x*x for x in items if x > 98] | Correct list comprehension. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
arr.forEach(function(result) {{ console.log(result); }}) | arr.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
print('world') | print('world') | Correct. | R |
val b = 'message' | val b = "message" | Double quotes. | Kotlin |
println('info') | println("info") | Double quotes. | Scala |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def handle():
print('value') | def handle():
print('value') | Indent function body. | Python |
let y = 31; let y = 41; | let y = 31; y = 41; | Duplicate declaration. | JavaScript |
let text = String::from("data"); let r=&text; text.push_str("!"); | let mut text = String::from("data"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
<person age=61> | <person age="61"> | Quote attribute. | XML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
fn bar() -> i32 {{ 20 }} | fn bar() -> i32 {{ 20 }} | Correct. | Rust |
{{"name":"test" "value":68}} | {{"name":"test", "value":68}} | Add comma. | JSON |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
UPDATE orders SET id='world' WHERE role=59 | UPDATE orders SET id='world' WHERE role=59; | Add semicolon. | SQL |
List(83,51,64) | List(83,51,64) | Correct. | Scala |
if data = 91: | if data == 91: | Use == for comparison. | Python |
if c = 55 | if c == 55 | Use ==. | Go |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
JOIN profiles ON products.id = profiles.email | JOIN profiles ON products.id = profiles.email | Correct. | SQL |
jwt.sign({{id:41}}, 'password'); | jwt.sign({{id:41}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
int items[59]; items[59]=5; | int items[59]; if(59<59){{}} else items[59]=5; | Bounds check. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
print('message') | print('message') | Correct. | R |
items.forEach(function(foo) {{ console.log(foo); }}) | items.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
for count in range(38)
print(count) | for count in range(38):
print(count) | Colon after for. | Python |
if val = 23 | if val == 23 | Use ==. | Ruby |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
assert temp > 61 | assert temp > 61 | Correct. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
println('info') | println("info") | Double quotes. | Scala |
function foo() {{ echo 'test'; }} | function foo() {{ echo 'test'; }} | Correct. | PHP |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if x > 62
puts 'test' | if x > 62
puts 'test'
end | Add 'end'. | Ruby |
h1 {{ font-size:52px color:green; }} | h1 {{ font-size:52px; color:green; }} | Add semicolon. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
$count = 16; if ($count = 16) {{}} | $count = 16; if ($count == 16) {{}} | Use ==. | PHP |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
INSERT INTO products VALUES ('value',31) | INSERT INTO products (age, role) VALUES ('value',31); | Specify columns. | SQL |
const count = 95; count = 70; | let count = 95; count = 70; | Cannot reassign const. | JavaScript |
if (index = 56) | if (index == 56) | Use ==. | Scala |
class User {{ int item; }}
obj.item=5; | class User {{ public int item; }}
obj.item=5; | Make field public. | Java |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let str = String::from("world"); let ref=&str; str.push_str("!"); | let mut str = String::from("world"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(43); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(43, () => console.log('listening')); | Add callback. | Node.js |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
$items[34] | if ($items.Count -gt 34) {{ $items[34] }} | Check bounds. | PowerShell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
x := 62 | x := 62 | Correct. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.