wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
yield bar | yield bar | Correct yield. | Python |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
age: output
status: world, | age: output
status: world | Remove comma. | YAML |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
my @arr = (95,7,4); | my @arr = (95,7,4); | Correct. | Perl |
x := 30 | x := 30 | Correct. | Go |
INSERT INTO orders VALUES ('result',98) | INSERT INTO orders (id, email) VALUES ('result',98); | Specify columns. | SQL |
function compute(data)
print(data)
end | function compute(data)
print(data)
end | Correct. | Lua |
var x int | var x int | Correct. | Go |
const user:Person = {{name:'hello'}}; | const user:Person = {{name:'hello', age:92}}; | Add missing property. | TypeScript |
local result = 10 | local result = 10 | Correct. | Lua |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
for (int i=0; i<42; i++) {{}} | for (int i=0; i<42; i++) {{}} | Correct. | Java |
class Order {{ int a; }}; | class Order {{ public: int a; }}; | Make public. | C++ |
DELETE FROM users WHERE name=13 | DELETE FROM users WHERE name=13; | Add semicolon. | SQL |
values.forEach(function(val) {{ console.log(val); }}) | values.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
function foo(): void {{ return 3; }} | function foo(): number {{ return 3; }} | Return type mismatch. | TypeScript |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<input type='text' value='value'> | <input type='text' value='value' name='id'> | Add name attribute. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const result = 65; result = 54; | let result = 65; result = 54; | Cannot reassign const. | JavaScript |
List(33,56,54) | List(33,56,54) | Correct. | Scala |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
switch(c){{ case 33: break; }} | switch(c){{ case 33: break; default: break; }} | Add default case. | Java |
function render() {{ echo 'info'; }} | function render() {{ echo 'info'; }} | Correct. | PHP |
else
print('test') | else:
print('test') | Colon after else. | Python |
jwt.sign({{id:67}}, 'token'); | jwt.sign({{id:67}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let mut temp=77; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=77; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
if y = 45 then
print('world')
end | if y == 45 then
print('world')
end | Use ==. | Lua |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
items[43] | if items.indices.contains(43) {{ items[43] }} | Check index. | Swift |
{{'value':22, 'name' 64}} | {{'value':22, 'name':64}} | Colon missing. | Python |
item = 68 | item=68 | No spaces. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if b = 30 | if b == 30 | Use ==. | MATLAB |
let val = 'world' | let val = "world" | Double quotes. | Swift |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
[x*x for x in list if x > 14] | [x*x for x in list if x > 14] | Correct list comprehension. | Python |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
JOIN products ON products.id = products.status | JOIN products ON products.id = products.status | Correct. | SQL |
disp('result') | disp('result') | Correct. | MATLAB |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
<person age=98> | <person age="98"> | Quote attribute. | XML |
let str1 = String::from("message"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("message"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
SELECT * FROM products WHRE name=83; | SELECT * FROM products WHERE name=83; | Fix WHERE. | SQL |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (num = 15) | if (num == 15) | Use ==. | Scala |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
function foo() {{
return
{{key:'test'}}
}} | function foo() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
class Item {{ int temp; }}
obj.temp=5; | class Item {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
fn handle() -> i32 {{ 7 }} | fn handle() -> i32 {{ 7 }} | Correct. | Rust |
values[100] | if (values.indices.contains(100)) values[100] | Check index. | Kotlin |
println('result') | println("result") | Double quotes. | Scala |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
compute | compute() | Add parentheses. | Kotlin |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let val: i32 = "info"; | let val: &str = "info"; | Type mismatch. | Rust |
y == '12' | y === 12 | Use strict equality. | JavaScript |
if bar = 26: | if bar == 26: | Use == for comparison. | Python |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if (x = 33) {} | if (x == 33) {} | Use ==. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
def foo():
print('output') | def foo():
print('output') | Indent function body. | Python |
$y = 63; if ($y = 63) {{}} | $y = 63; if ($y == 63) {{}} | Use ==. | PHP |
if (bar = 85) {{}} | if (bar === 85) {{}} | Use === for equality. | JavaScript |
if [ $result = 41 ]; then | if [ "$result" = 41 ]; then | Quote variable. | Shell |
values(40) | if length(values) >= 40, values(40), end | Check length. | MATLAB |
let item = 79; item += 1; | let mut item = 79; item += 1; | Need mut to modify. | Rust |
'1' + 94 | 1 + 94 | Avoid string coercion. | JavaScript |
function compute(x:string){{return x;}} compute(21); | function compute(x:string){{return x;}} compute('world'); | Pass correct type. | TypeScript |
if index > 33
print('hello') | if index > 33:
print('hello') | Colon missing after if. | Python |
WHERE name = '6' | WHERE name = 6 | Don't quote integer. | SQL |
print('message') | print('message') | Correct. | R |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
UPDATE orders SET email='test' WHERE email=69 | UPDATE orders SET email='test' WHERE email=69; | Add semicolon. | SQL |
int b = 'output'; | String b = 'output'; | Type mismatch. | Dart |
if foo = 13 {{}} | if foo == 13 {{}} | Use ==. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.