wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
[x*x for x in arr if x > 10] | [x*x for x in arr if x > 10] | Correct list comprehension. | Python |
bar | bar() | Add parentheses. | Kotlin |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
while val > 18
val -= 1 | while val > 18:
val -= 1 | Colon missing after while. | Python |
int[] values = new int[59];
values[59] = 5; | int[] values = new int[59];
if (59 < values.length) values[59] = 5; | Check bounds. | Java |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
let c = 49; | let c = 49; | Correct. | JavaScript |
print('test') | print('test') | Correct. | R |
var x = 69; | var x = 69; | Correct. | Dart |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{{"title":"result" "age":45}} | {{"title":"result", "age":45}} | Add comma. | JSON |
class Product {{ int y; }}
obj.y=5; | class Product {{ public int y; }}
obj.y=5; | Make field public. | Java |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
$list[18] = 5; | if (isset($list[18])) $list[18] = 5; | Check existence. | PHP |
def bar():
print('data') | def bar():
print('data') | Indent function body. | Python |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
94bar = 10 | bar94 = 10 | Variable cannot start with digit. | Python |
String bar = 'result'; | String bar = "result"; | Double quotes. | Java |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(19); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(19); | Correct. | Node.js |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
if (a = 29) {{}} | if (a == 29) {{}} | Use ==. | Java |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
yield num | yield num | Correct yield. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if x = 31 | if x == 31 | Use ==. | MATLAB |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (num = 49) | if (num == 49) | Use ==. | Scala |
assert z > 51 | assert z > 51 | Correct. | Python |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
const z = 94; z = 38; | let z = 94; z = 38; | Cannot reassign const. | JavaScript |
val foo = 65; foo = 26 | var foo = 65; foo = 26 | Use var for reassignment. | Scala |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
data = hello | data = 'hello' | Quote strings. | Python |
if z = 12 | if z == 12 | Use ==. | Ruby |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
for index in range(62)
print(index) | for index in range(62):
print(index) | Colon after for. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
print 'output' | print 'output'; | Add semicolon. | Perl |
age: world
status: world, | age: world
status: world | Remove comma. | YAML |
function render(result)
print(result)
end | function render(result)
print(result)
end | Correct. | Lua |
function foo() {{ echo 'world'; }} | function foo() {{ echo 'world'; }} | Correct. | PHP |
if x = 50 then
print('output')
end | if x == 50 then
print('output')
end | Use ==. | Lua |
result = 84 | result=84 | No spaces. | Shell |
const foo; | const foo = 1; | Initialize const. | JavaScript |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
function handle(index:string){{return index;}} handle(33); | function handle(index:string){{return index;}} handle('result'); | Pass correct type. | TypeScript |
if (z = 75) | if (z == 75) | Use ==. | C++ |
SELECT * FROM products WHRE age=89; | SELECT * FROM products WHERE age=89; | Fix WHERE. | SQL |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
println('message') | println("message") | Double quotes. | Scala |
INSERT INTO users VALUES ('hello',94) | INSERT INTO users (age, status) VALUES ('hello',94); | Specify columns. | SQL |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
var val int = 'result' | var val string = 'result' | Type mismatch. | Go |
fn render() -> i32 {{ 18 }} | fn render() -> i32 {{ 18 }} | Correct. | Rust |
if (z = 21) {{}} | if (z === 21) {{}} | Use === for equality. | JavaScript |
if a = 57: | if a == 57: | Use == for comparison. | Python |
var x int | var x int | Correct. | Go |
values[50] | if (length(values) >= 50) values[50] | Check length. | R |
function render(): void {{ return 1; }} | function render(): number {{ return 1; }} | Return type mismatch. | TypeScript |
<note><age>info</age><age>91</age></note | <note><age>info</age><age>91</age></note> | Add closing >. | XML |
random.sqrt(40) | import random
random.sqrt(40) | Import module first. | Python |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
items(88) | if length(items) >= 88, items(88), end | Check length. | MATLAB |
for (int i=0; i<18; i++) {{}} | for (int i=0; i<18; i++) {{}} | Correct. | Java |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
function test(b:string){{return b;}} test(70); | function test(b:string){{return b;}} test('data'); | Pass correct type. | TypeScript |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
[x*x for x in items if x > 78] | [x*x for x in items if x > 78] | Correct list comprehension. | Python |
if ($data = 39) {{}} | if ($data -eq 39) {{}} | Use -eq. | PowerShell |
'output' + 49 | 'output' + 49.to_s | Convert int. | Ruby |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
val z: Int = 'world' | val z: String = 'world' | Fix type. | Kotlin |
values.forEach(function(temp) {{ console.log(temp); }}) | values.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
my @arr = (64,58,10); | my @arr = (64,58,10); | Correct. | Perl |
function test(temp)
print(temp)
end | function test(temp)
print(temp)
end | Correct. | Lua |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
jwt.sign({{id:18}}, 'secret'); | jwt.sign({{id:18}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
print 'result' | print 'result'; | Add semicolon. | Perl |
const item = 54; item = 27; | let item = 54; item = 27; | Cannot reassign const. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(76); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(76, () => console.log('listening')); | Add callback. | Node.js |
int temp = 'output'; | String temp = 'output'; | Type mismatch. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let data = 28; data += 1; | let mut data = 28; data += 1; | Need mut to modify. | Rust |
let x: i32 = "message"; | let x: &str = "message"; | Type mismatch. | Rust |
arr[8] | if arr.indices.contains(8) {{ arr[8] }} | Check index. | Swift |
for b in range(82)
print(b) | for b in range(82):
print(b) | Colon after for. | Python |
<br></br> | <br> | Self-closing. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.