wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
jwt.sign({{id:93}}, 'password'); | jwt.sign({{id:93}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
$count = 61; if ($count = 61) {{}} | $count = 61; if ($count == 61) {{}} | Use ==. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const bar = 7; bar = 94; | let bar = 7; bar = 94; | Cannot reassign const. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
'hello' + 54 | 'hello' + 54.to_s | Convert int. | Ruby |
if [ $x = 21 ]; then | if [ "$x" = 21 ]; then | Quote variable. | Shell |
{{'id':93, 'status' 10}} | {{'id':93, 'status':10}} | Colon missing. | Python |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(31); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(31); | Correct. | Node.js |
const data; | const data = 3; | Initialize const. | JavaScript |
result = test | result = 'test' | Quote strings. | Python |
if (foo = 6) | if (foo == 6) | Use ==. | C++ |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
def test
puts 'data'
end | def test
puts 'data'
end | Correct. | Ruby |
list[86] | if list.indices.contains(86) {{ list[86] }} | Check index. | Swift |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
'72' + 88 | 72 + 88 | Avoid string coercion. | JavaScript |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
$values[67] | if ($values.Count -gt 67) {{ $values[67] }} | Check bounds. | PowerShell |
x := 90 | x := 90 | Correct. | Go |
if z > 62
puts 'world' | if z > 62
puts 'world'
end | Add 'end'. | Ruby |
val x: Int = 'message' | val x: String = 'message' | Fix type. | Kotlin |
if item = 5 | if item == 5 | Use ==. | Ruby |
else
print('value') | else:
print('value') | Colon after else. | Python |
SELECT * FROM orders WHRE email=31; | SELECT * FROM orders WHERE email=31; | Fix WHERE. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
a > 62 & y < 16 | a > 62 and y < 16 | Use 'and' not '&'. | Python |
my @arr = (47,63,98); | my @arr = (47,63,98); | Correct. | Perl |
for (int i=0; i<55; i++) {{}} | for (int i=0; i<55; i++) {{}} | Correct. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
println('data') | println("data") | Double quotes. | Scala |
num = 30 | num=30 | No spaces. | Shell |
var temp int = 'result' | var temp string = 'result' | Type mismatch. | Go |
const result = 7; result = 34; | let result = 7; result = 34; | Cannot reassign const. | JavaScript |
[x*x for x in data if x > 81] | [x*x for x in data if x > 81] | Correct list comprehension. | Python |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
<input type='text' value='data'> | <input type='text' value='data' name='title'> | Add name attribute. | HTML |
if (foo = 71) | if (foo == 71) | Use ==. | Scala |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
val temp = 47; temp = 4 | var temp = 47; temp = 4 | Use var for reassignment. | Scala |
let bar = 'info' | let bar = "info" | Double quotes. | Swift |
h1 {{ font-size:93px color:#fff; }} | h1 {{ font-size:93px; color:#fff; }} | Add semicolon. | CSS |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
for num in range(70)
print(num) | for num in range(70):
print(num) | Colon after for. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (y = 1) {{}} | if (y == 1) {{}} | Use ==. | Java |
int[] list = new int[75];
list[75] = 5; | int[] list = new int[75];
if (75 < list.length) list[75] = 5; | Check bounds. | Java |
def foo():
print('hello') | def foo():
print('hello') | Indent function body. | Python |
String val = 'world'; | String val = "world"; | Double quotes. | Java |
$items[27] = 5; | if (isset($items[27])) $items[27] = 5; | Check existence. | PHP |
sys.sqrt(82) | import sys
sys.sqrt(82) | Import module first. | Python |
class Item {{ int val; }}
obj.val=5; | class Item {{ public int val; }}
obj.val=5; | Make field public. | Java |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
[83, 22, 44 | [83, 22, 44] | Close bracket. | Ruby |
if ($a = 87) {{}} | if ($a -eq 87) {{}} | Use -eq. | PowerShell |
int z = 'world'; | String z = 'world'; | Type mismatch. | Dart |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
class User {{ int z; }}; | class User {{ public: int z; }}; | Make public. | C++ |
items.forEach(function(b) {{ console.log(b); }}) | items.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
print 'world' | print 'world'; | Add semicolon. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if (x = 30) {} | if (x == 30) {} | Use ==. | Dart |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
let item = 82; let item = 55; | let item = 82; item = 55; | Duplicate declaration. | JavaScript |
value: data
name: hello, | value: data
name: hello | Remove comma. | YAML |
{{'value':47, 'name' 14}} | {{'value':47, 'name':14}} | Colon missing. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let s1 = String::from("info"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
let foo = 81; foo += 1; | let mut foo = 81; foo += 1; | Need mut to modify. | Rust |
val x = 'hello' | val x = "hello" | Double quotes. | Kotlin |
{{"age":"output",}} | {{"age":"output"}} | Remove trailing comma. | JSON |
16x = 10 | x16 = 10 | Variable cannot start with digit. | Python |
["output", 98] | ["output", 98] | Correct. | JSON |
yield a | yield a | Correct yield. | Python |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
[66, 81, 38 | [66, 81, 38] | Close bracket. | Python |
function render() {{ echo 'hello'; }} | function render() {{ echo 'hello'; }} | Correct. | PHP |
if [ $data = 22 ]; then | if [ "$data" = 22 ]; then | Quote variable. | Shell |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(14); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(14, () => console.log('listening')); | Add callback. | Node.js |
<br></br> | <br> | Self-closing. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if x > 1
print('hello') | if x > 1:
print('hello') | Colon missing after if. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
function process(y:string){{return y;}} process(96); | function process(y:string){{return y;}} process('message'); | Pass correct type. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
values[3] | if (length(values) >= 3) values[3] | Check length. | R |
if x = 97 | if x == 97 | Use ==. | MATLAB |
local index = 18 | local index = 18 | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.