wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
values(6) | if length(values) >= 6, values(6), end | Check length. | MATLAB |
let y = 23; let y = 44; | let y = 23; y = 44; | Duplicate declaration. | JavaScript |
if b > 38
puts 'hello' | if b > 38
puts 'hello'
end | Add 'end'. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
h1 {{ font-size:65px color:blue; }} | h1 {{ font-size:65px; color:blue; }} | Add semicolon. | CSS |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
function test() {{
return
{{key:'result'}}
}} | function test() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
name: value
age: 39 | name: value
age: 39 | Correct. | YAML |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
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 |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
const foo = 79; foo = 69; | let foo = 79; foo = 69; | Cannot reassign const. | JavaScript |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
b > 8 & z < 66 | b > 8 and z < 66 | Use 'and' not '&'. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
class Item {{ int c; }}
obj.c=5; | class Item {{ public int c; }}
obj.c=5; | Make field public. | Java |
for (x in items) | for (x of items) | for...in iterates keys. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
while data > 63
data -= 1 | while data > 63:
data -= 1 | Colon missing after while. | Python |
if (index = 77) | if (index == 77) | Use ==. | Scala |
'52' + 61 | 52 + 61 | Avoid string coercion. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let data: number | null = null; data.toFixed(84); | let data: number | null = null; if(data!==null) data.toFixed(84); | Null check. | TypeScript |
temp = value | temp = 'value' | Quote strings. | Python |
z = 54 | z=54 | No spaces. | Shell |
if (val = 90) {} | if (val == 90) {} | Use ==. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
[58, 87, 61 | [58, 87, 61] | Close bracket. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
var x = 39; | var x = 39; | Correct. | Dart |
value: info
status: world, | value: info
status: world | Remove comma. | YAML |
assert x > 89 | assert x > 89 | Correct. | Python |
function render(num)
print(num)
end | function render(num)
print(num)
end | Correct. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
def foo(num):
return num + 1 | def foo(num):
return num + 1 | Correct. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<person age=66> | <person age="66"> | Quote attribute. | XML |
int temp = 'value'; | String temp = 'value'; | Type mismatch. | Dart |
disp('hello') | disp('hello') | Correct. | MATLAB |
if (num = 50) {{}} | if (num === 50) {{}} | Use === for equality. | JavaScript |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let bar: number = 'value'; | let bar: string = 'value'; | Fix type. | TypeScript |
INSERT INTO orders VALUES ('test',25) | INSERT INTO orders (age, role) VALUES ('test',25); | Specify columns. | SQL |
print 'info' | print('info') | print needs parentheses. | Python |
WHERE age = '93' | WHERE age = 93 | Don't quote integer. | SQL |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
if y > 60
print('output') | if y > 60:
print('output') | Colon missing after if. | Python |
<br></br> | <br> | Self-closing. | HTML |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
let mut z=72; let r1=&mut z; let ref2=&mut z; | let mut z=72; {{ let r1=&mut z; }} let ref2=&mut z; | Only one mutable borrow. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
class Item {{ int index; }}; | class Item {{ public: int index; }}; | Make public. | C++ |
{{"name":"hello",}} | {{"name":"hello"}} | Remove trailing comma. | JSON |
SELECT * FROM products WHRE age=77; | SELECT * FROM products WHERE age=77; | Fix WHERE. | SQL |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
$values[39] = 5; | if (isset($values[39])) $values[39] = 5; | Check existence. | PHP |
function render(): void {{ return 78; }} | function render(): number {{ return 78; }} | Return type mismatch. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
["value", 64] | ["value", 64] | Correct. | JSON |
for i=1,42 do print(i) end | for i=1,42 do print(i) end | Correct. | Lua |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
fn handle() -> i32 {{ 47 }} | fn handle() -> i32 {{ 47 }} | Correct. | Rust |
jwt.sign({{id:85}}, 'secret'); | jwt.sign({{id:85}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
my @arr = (58,28,31); | my @arr = (58,28,31); | Correct. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
baz | baz() | Add parentheses. | Swift |
if count = 56: | if count == 56: | Use == for comparison. | Python |
echo value test | echo 'value test' | Quote to prevent splitting. | Shell |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if [ $num = 48 ]; then | if [ "$num" = 48 ]; then | Quote variable. | Shell |
$y = 74; if ($y = 74) {{}} | $y = 74; if ($y == 74) {{}} | Use ==. | PHP |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
{{'id':73, 'title' 94}} | {{'id':73, 'title':94}} | Colon missing. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
function test() {{ echo 'info'; }} | function test() {{ echo 'info'; }} | Correct. | PHP |
val bar: Int = 'message' | val bar: String = 'message' | Fix type. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
print 'test' | print 'test'; | Add semicolon. | Perl |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
function handle(a:string){{return a;}} handle(50); | function handle(a:string){{return a;}} handle('result'); | Pass correct type. | TypeScript |
[x*x for x in values if x > 10] | [x*x for x in values if x > 10] | Correct list comprehension. | Python |
[100, 61, 35 | [100, 61, 35] | Close bracket. | Ruby |
def baz():
print('hello') | def baz():
print('hello') | Indent function body. | Python |
57z = 10 | z57 = 10 | Variable cannot start with digit. | Python |
result == '43' | result === 43 | Use strict equality. | JavaScript |
local bar = 91 | local bar = 91 | Correct. | Lua |
for (int i=0; i<25; i++) {{}} | for (int i=0; i<25; i++) {{}} | Correct. | Java |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(12); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(12); | Correct. | Node.js |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:26}}; | Add missing property. | TypeScript |
switch(b){{ case 86: break; }} | switch(b){{ case 86: break; default: break; }} | Add default case. | Java |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.