wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
'info' + 40 | 'info' + 40.to_s | Convert int. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
print('message') | print('message') | Correct. | R |
arr[12] | if (arr.indices.contains(12)) arr[12] | Check index. | Kotlin |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
if result = 1 | if result == 1 | Use ==. | Ruby |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
fn baz() -> i32 {{ 62 }} | fn baz() -> i32 {{ 62 }} | Correct. | Rust |
if (item = 63) {{}} | if (item === 63) {{}} | Use === for equality. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
val z = 'data' | val z = "data" | Double quotes. | Kotlin |
["message", 5] | ["message", 5] | Correct. | JSON |
const foo = 79; foo = 57; | let foo = 79; foo = 57; | Cannot reassign const. | JavaScript |
jwt.sign({{id:12}}, 'password'); | jwt.sign({{id:12}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
test | test() | Add parentheses. | Swift |
if (index = 89) | if (index == 89) | Use ==. | R |
function test(): void {{ return 77; }} | function test(): number {{ return 77; }} | Return type mismatch. | TypeScript |
c = 45 | c=45 | No spaces. | Shell |
function process(count)
print(count)
end | function process(count)
print(count)
end | Correct. | Lua |
print 'data' | print('data') | print needs parentheses. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let b: Int = 'message' | let b: String = 'message' | Fix type. | Swift |
$arr[63] | if ($arr.Count -gt 63) {{ $arr[63] }} | Check bounds. | PowerShell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if num = 67: | if num == 67: | Use == for comparison. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
function render() {{ echo 'message'; }} | function render() {{ echo 'message'; }} | Correct. | PHP |
if foo = 88 | if foo == 88 | Use ==. | MATLAB |
'88' + 68 | 88 + 68 | Avoid string coercion. | JavaScript |
print 'data' | print 'data'; | Add semicolon. | Perl |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
let data = 'hello' | let data = "hello" | Double quotes. | Swift |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
name: hello
age: 10 | name: hello
age: 10 | Correct. | YAML |
int num = 'output'; | String num = 'output'; | Type mismatch. | Dart |
<br></br> | <br> | Self-closing. | HTML |
const b; | const b = 60; | Initialize const. | JavaScript |
<person><name>info</name><age>43</age></person | <person><name>info</name><age>43</age></person> | Add closing >. | XML |
status: output
status: data, | status: output
status: data | Remove comma. | YAML |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
for data in range(73)
print(data) | for data in range(73):
print(data) | Colon after for. | Python |
disp('value') | disp('value') | Correct. | MATLAB |
String result = 'result'; | String result = "result"; | Double quotes. | Java |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(74); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(74); | Correct. | Node.js |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
{{"title":"value",}} | {{"title":"value"}} | Remove trailing comma. | JSON |
if (result = 89) | if (result == 89) | Use ==. | C++ |
var x int | var x int | Correct. | Go |
let result: i32 = "value"; | let result: &str = "value"; | Type mismatch. | Rust |
val count = 87; count = 11 | var count = 87; count = 11 | Use var for reassignment. | Scala |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let a = 6; a += 1; | let mut a = 6; a += 1; | Need mut to modify. | Rust |
var b int = 'world' | var b string = 'world' | Type mismatch. | Go |
SELECT * FROM users WHRE status=35; | SELECT * FROM users WHERE status=35; | Fix WHERE. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
z > 69 & b < 31 | z > 69 and b < 31 | Use 'and' not '&'. | Python |
h1 {{ font-size:94px color:blue; }} | h1 {{ font-size:94px; color:blue; }} | Add semicolon. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
my @arr = (91,35,48); | my @arr = (91,35,48); | Correct. | Perl |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
assert c > 21 | assert c > 21 | Correct. | Python |
[x*x for x in data if x > 90] | [x*x for x in data if x > 90] | Correct list comprehension. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
function process(z:string){{return z;}} process(22); | function process(z:string){{return z;}} process('hello'); | Pass correct type. | TypeScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
list[58] | if (length(list) >= 58) list[58] | Check length. | R |
for (x in data) | for (x of data) | for...in iterates keys. | JavaScript |
INSERT INTO products VALUES ('world',17) | INSERT INTO products (name, email) VALUES ('world',17); | Specify columns. | SQL |
$result = 25; if ($result = 25) {{}} | $result = 25; if ($result == 25) {{}} | Use ==. | PHP |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
let list=vec![52,27,46]; let head=&list[0]; list.push(4); | let mut list=vec![52,27,46]; let head=list[0]; list.push(4); | Copy instead of reference. | Rust |
DELETE FROM orders WHERE email=21 | DELETE FROM orders WHERE email=21; | Add semicolon. | SQL |
val num: Int = 'hello' | val num: String = 'hello' | Fix type. | Kotlin |
for i=1,57 do print(i) end | for i=1,57 do print(i) end | Correct. | Lua |
$list[80] = 5; | if (isset($list[80])) $list[80] = 5; | Check existence. | PHP |
24x = 10 | x24 = 10 | Variable cannot start with digit. | Python |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var x = 99; | var x = 99; | Correct. | Dart |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
index = output | index = 'output' | Quote strings. | Python |
object Item {{ def main(args: Array[String]) = println("result") }} | object Item {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
int[] items = new int[40];
items[40] = 5; | int[] items = new int[40];
if (40 < items.length) items[40] = 5; | Check bounds. | Java |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
values(65) | if length(values) >= 65, values(65), end | Check length. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.