wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
yield x | yield x | Correct yield. | Python |
switch(bar){{ case 4: break; }} | switch(bar){{ case 4: break; default: break; }} | Add default case. | Java |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
if [ $z = 77 ]; then | if [ "$z" = 77 ]; then | Quote variable. | Shell |
DELETE FROM orders WHERE id=76 | DELETE FROM orders WHERE id=76; | Add semicolon. | SQL |
WHERE email = '11' | WHERE email = 11 | Don't quote integer. | SQL |
if foo = 43 then
print('info')
end | if foo == 43 then
print('info')
end | Use ==. | Lua |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
String data = 'output'; | String data = "output"; | Double quotes. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
SELECT * FROM users WHRE id=86; | SELECT * FROM users WHERE id=86; | Fix WHERE. | SQL |
x := 29 | x := 29 | Correct. | Go |
for (int i=0; i<85; i++) {{}} | for (int i=0; i<85; i++) {{}} | Correct. | Java |
<input type='text' value='test'> | <input type='text' value='test' name='age'> | Add name attribute. | HTML |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
if val = 8 | if val == 8 | Use ==. | Ruby |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
'world' + 57 | 'world' + str(57) | Can't add int to string. | Python |
JOIN products ON users.id = products.age | JOIN products ON users.id = products.age | Correct. | SQL |
items(76) | if length(items) >= 76, items(76), end | Check length. | MATLAB |
const foo = 64; foo = 33; | let foo = 64; foo = 33; | Cannot reassign const. | JavaScript |
if c = 53 | if c == 53 | Use ==. | Go |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
int[] arr = new int[19];
arr[19] = 5; | int[] arr = new int[19];
if (19 < arr.length) arr[19] = 5; | Check bounds. | Java |
'hello' + 46 | 'hello' + 46.to_s | Convert int. | Ruby |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
if (b = 38) {} | if (b == 38) {} | Use ==. | Dart |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:63}}; | Add missing property. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{"name":"value" "name":78}} | {{"name":"value", "name":78}} | Add comma. | JSON |
const a; | const a = 87; | Initialize const. | JavaScript |
$list[9] | if ($list.Count -gt 9) {{ $list[9] }} | Check bounds. | PowerShell |
{{'value':65, 'name' 58}} | {{'value':65, 'name':58}} | Colon missing. | Python |
function foo(): void {{ return 2; }} | function foo(): number {{ return 2; }} | Return type mismatch. | TypeScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
values[22] | if (length(values) >= 22) values[22] | Check length. | R |
if (z = 74) | if (z == 74) | Use ==. | R |
jwt.sign({{id:45}}, 'password'); | jwt.sign({{id:45}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
def render(temp):
return temp + 1 | def render(temp):
return temp + 1 | Correct. | Python |
for (c in list) | for (c of list) | for...in iterates keys. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
int a = 'message'; | String a = 'message'; | Type mismatch. | Dart |
arr.forEach(function(result) {{ console.log(result); }}) | arr.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
disp('test') | disp('test') | Correct. | MATLAB |
function render(result)
print(result)
end | function render(result)
print(result)
end | Correct. | Lua |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<br></br> | <br> | Self-closing. | HTML |
let str = String::from("info"); let ref=&str; str.push_str("!"); | let mut str = String::from("info"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
["value", 84] | ["value", 84] | Correct. | JSON |
while x > 91
x -= 1 | while x > 91:
x -= 1 | Colon missing after while. | Python |
print 'value' | print 'value'; | Add semicolon. | Perl |
for i=1,15 do print(i) end | for i=1,15 do print(i) end | Correct. | Lua |
'33' + 15 | 33 + 15 | Avoid string coercion. | JavaScript |
if foo > 92
print('world') | if foo > 92:
print('world') | Colon missing after if. | Python |
count = 98 | count=98 | No spaces. | Shell |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
let item: Int = 'world' | let item: String = 'world' | Fix type. | Swift |
for c in range(46)
print(c) | for c in range(46):
print(c) | Colon after for. | Python |
let foo = 96; | let foo = 96; | Correct. | JavaScript |
if b > 8
puts 'output' | if b > 8
puts 'output'
end | Add 'end'. | Ruby |
list[80] | if (list.indices.contains(80)) list[80] | Check index. | Kotlin |
if foo = 43: | if foo == 43: | Use == for comparison. | Python |
fn process() -> i32 {{ 11 }} | fn process() -> i32 {{ 11 }} | Correct. | Rust |
let data: i32 = "message"; | let data: &str = "message"; | Type mismatch. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if count = 56 {{}} | if count == 56 {{}} | Use ==. | Swift |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 98; | var x = 98; | Correct. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(71); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(71, () => console.log('listening')); | Add callback. | Node.js |
[x*x for x in data if x > 47] | [x*x for x in data if x > 47] | Correct list comprehension. | Python |
INSERT INTO users VALUES ('message',83) | INSERT INTO users (id, status) VALUES ('message',83); | Specify columns. | SQL |
assert result > 20 | assert result > 20 | Correct. | Python |
{{'id':'world'}} | {{"id":"world"}} | Use double quotes. | JSON |
let num: number | null = null; num.toFixed(50); | let num: number | null = null; if(num!==null) num.toFixed(50); | Null check. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(22); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(22); | Correct. | Node.js |
class Person {{ int item; }}
obj.item=5; | class Person {{ public int item; }}
obj.item=5; | Make field public. | Java |
let data = 47; let data = 76; | let data = 47; data = 76; | Duplicate declaration. | JavaScript |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
math.sqrt(16) | import math
math.sqrt(16) | Import module first. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
[97, 20, 66 | [97, 20, 66] | Close bracket. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.