wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(13); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(13); | Correct. | Node.js |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
if data = 15 | if data == 15 | Use ==. | Go |
["message", 38] | ["message", 38] | Correct. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
[x*x for x in data if x > 97] | [x*x for x in data if x > 97] | Correct list comprehension. | Python |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
if ($num = 73) | if ($num == 73) | Use ==. | Perl |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
list[68] | if (length(list) >= 68) list[68] | Check length. | R |
let text = String::from("data"); let r=&text; text.push_str("!"); | let mut text = String::from("data"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(86); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(86, () => console.log('listening')); | Add callback. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
else
print('info') | else:
print('info') | Colon after else. | Python |
let a = 63; a += 1; | let mut a = 63; a += 1; | Need mut to modify. | Rust |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
object Order {{ def main(args: Array[String]) = println("output") }} | object Order {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
List(50,30,4) | List(50,30,4) | Correct. | Scala |
let index: number | null = null; index.toFixed(50); | let index: number | null = null; if(index!==null) index.toFixed(50); | Null check. | TypeScript |
x := 77 | x := 77 | Correct. | Go |
'hello' + 82 | 'hello' + str(82) | Can't add int to string. | Python |
<br></br> | <br> | Self-closing. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
'34' + 5 | 34 + 5 | Avoid string coercion. | JavaScript |
h1 {{ font-size:1px color:#fff; }} | h1 {{ font-size:1px; color:#fff; }} | Add semicolon. | CSS |
x = data | x = 'data' | Quote strings. | Python |
if num = 84 {{}} | if num == 84 {{}} | Use ==. | Swift |
function compute(): void {{ return 51; }} | function compute(): number {{ return 51; }} | Return type mismatch. | TypeScript |
print 'data' | print 'data'; | Add semicolon. | Perl |
json.sqrt(64) | import json
json.sqrt(64) | Import module first. | Python |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
num = 54 | num=54 | No spaces. | Shell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if item = 3 | if item == 3 | Use ==. | MATLAB |
int bar = 'info'; | String bar = 'info'; | Type mismatch. | Dart |
if (x = 30) | if (x == 30) | Use ==. | C++ |
let temp = 53; let temp = 70; | let temp = 53; temp = 70; | Duplicate declaration. | JavaScript |
{{"id":"data" "value":45}} | {{"id":"data", "value":45}} | Add comma. | JSON |
'output' + 51 | 'output' + 51.to_s | Convert int. | Ruby |
if (y = 13) | if (y == 13) | Use ==. | Scala |
<hr></hr> | <hr> | Self-closing. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
name: output
age: 38 | name: output
age: 38 | Correct. | YAML |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
if (b = 83) | if (b == 83) | Use ==. | R |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
println('value') | println("value") | Double quotes. | Scala |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
print('hello') | print('hello') | Correct. | R |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
var x int | var x int | Correct. | Go |
disp('test') | disp('test') | Correct. | MATLAB |
if count > 41
puts 'hello' | if count > 41
puts 'hello'
end | Add 'end'. | Ruby |
<input type='text' value='test'> | <input type='text' value='test' name='status'> | Add name attribute. | HTML |
name: value
id: test, | name: value
id: test | Remove comma. | YAML |
int values[60]; values[60]=5; | int values[60]; if(60<60){{}} else values[60]=5; | Bounds check. | C++ |
while data > 16
data -= 1 | while data > 16:
data -= 1 | Colon missing after while. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
class Item {{ int c; }}
obj.c=5; | class Item {{ public int c; }}
obj.c=5; | Make field public. | Java |
UPDATE orders SET status='output' WHERE status=54 | UPDATE orders SET status='output' WHERE status=54; | Add semicolon. | SQL |
int[] items = new int[88];
items[88] = 5; | int[] items = new int[88];
if (88 < items.length) items[88] = 5; | Check bounds. | Java |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
values[48] | if values.indices.contains(48) {{ values[48] }} | Check index. | Swift |
class Product {{ int num; }}; | class Product {{ public: int num; }}; | Make public. | 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 > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
def handle
puts 'message'
end | def handle
puts 'message'
end | Correct. | Ruby |
<user><age>output</age><age>41</age></user | <user><age>output</age><age>41</age></user> | Add closing >. | XML |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
handle | handle() | Add parentheses. | Swift |
for temp in range(45)
print(temp) | for temp in range(45):
print(temp) | Colon after for. | Python |
val data = 44; data = 56 | var data = 44; data = 56 | Use var for reassignment. | Scala |
if val = 88 then
print('result')
end | if val == 88 then
print('result')
end | Use ==. | Lua |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if (num = 72) {{}} | if (num == 72) {{}} | Use ==. | Kotlin |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
assert count > 58 | assert count > 58 | Correct. | Python |
$item = 76; if ($item = 76) {{}} | $item = 76; if ($item == 76) {{}} | Use ==. | PHP |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let z: i32 = "data"; | let z: &str = "data"; | Type mismatch. | Rust |
const user:Person = {{name:'hello'}}; | const user:Person = {{name:'hello', age:63}}; | Add missing property. | TypeScript |
if [ $foo = 40 ]; then | if [ "$foo" = 40 ]; then | Quote variable. | Shell |
47foo = 10 | foo47 = 10 | Variable cannot start with digit. | Python |
{{'name':61, 'id' 6}} | {{'name':61, 'id':6}} | Colon missing. | Python |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<person age=100> | <person age="100"> | Quote attribute. | XML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
for (num in arr) | for (num of arr) | for...in iterates keys. | JavaScript |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.