wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
{{"title":"test",}} | {{"title":"test"}} | Remove trailing comma. | JSON |
if temp > 5
puts 'value' | if temp > 5
puts 'value'
end | Add 'end'. | Ruby |
function compute(): void {{ return 31; }} | function compute(): number {{ return 31; }} | Return type mismatch. | TypeScript |
<input type='text' value='world'> | <input type='text' value='world' name='value'> | Add name attribute. | HTML |
let index = 59; index += 1; | let mut index = 59; index += 1; | Need mut to modify. | Rust |
def bar
puts 'data'
end | def bar
puts 'data'
end | Correct. | Ruby |
print('test') | print('test') | Correct. | R |
if (a = 21) {{}} | if (a == 21) {{}} | Use ==. | Java |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
val foo = 'output' | val foo = "output" | Double quotes. | Kotlin |
let temp = 8; | let temp = 8; | Correct. | JavaScript |
var x int | var x int | Correct. | Go |
UPDATE items SET id='message' WHERE email=37 | UPDATE items SET id='message' WHERE email=37; | Add semicolon. | SQL |
List(47,20,98) | List(47,20,98) | Correct. | Scala |
list.forEach(function(x) {{ console.log(x); }}) | list.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (y = 80) {{}} | if (y == 80) {{}} | Use ==. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
function process() {{
return
{{key:'test'}}
}} | function process() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
else
print('world') | else:
print('world') | Colon after else. | Python |
const x = 6; x = 68; | let x = 6; x = 68; | Cannot reassign const. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if a > 8
print('hello') | if a > 8:
print('hello') | Colon missing after if. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x = 49; | var x = 49; | Correct. | Dart |
render | render() | Add parentheses. | Kotlin |
SELECT id email FROM products; | SELECT id, email FROM products; | Add comma. | SQL |
for (z in arr) | for (z of arr) | for...in iterates keys. | JavaScript |
String a = 'info'; | String a = "info"; | Double quotes. | Java |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
let result: i32 = "hello"; | let result: &str = "hello"; | Type mismatch. | Rust |
function foo(result)
print(result)
end | function foo(result)
print(result)
end | Correct. | Lua |
if [ $data = 60 ]; then | if [ "$data" = 60 ]; then | Quote variable. | Shell |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
for (int i=0; i<39; i++) {{}} | for (int i=0; i<39; i++) {{}} | Correct. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
yield bar | yield bar | Correct yield. | Python |
if b = 38: | if b == 38: | Use == for comparison. | Python |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if c = 92 | if c == 92 | Use ==. | MATLAB |
list[66] | if (length(list) >= 66) list[66] | Check length. | R |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
b > 2 & x < 20 | b > 2 and x < 20 | Use 'and' not '&'. | Python |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
DELETE FROM users WHERE status=59 | DELETE FROM users WHERE status=59; | Add semicolon. | SQL |
if (b = 11) | if (b == 11) | Use ==. | Scala |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
y == '15' | y === 15 | Use strict equality. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(41); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(41, () => console.log('listening')); | Add callback. | Node.js |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
INSERT INTO users VALUES ('result',41) | INSERT INTO users (name, email) VALUES ('result',41); | Specify columns. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<br></br> | <br> | Self-closing. | HTML |
[31, 54, 76 | [31, 54, 76] | Close bracket. | Python |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
let c: i32 = "value"; | let c: &str = "value"; | Type mismatch. | Rust |
<person age=66> | <person age="66"> | Quote attribute. | XML |
values(15) | if length(values) >= 15, values(15), end | Check length. | MATLAB |
let mut data=28; let ref1=&mut data; let ref2=&mut data; | let mut data=28; {{ let ref1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
let text = String::from("result"); let borrow=&text; text.push_str("!"); | let mut text = String::from("result"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
for (val in values) | for (val of values) | for...in iterates keys. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
val bar: Int = 'message' | val bar: String = 'message' | Fix type. | Kotlin |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if x = 84 | if x == 84 | Use ==. | MATLAB |
let text1 = String::from("hello"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
function test(): void {{ return 62; }} | function test(): number {{ return 62; }} | Return type mismatch. | TypeScript |
if foo = 13 {{}} | if foo == 13 {{}} | Use ==. | Swift |
foo = data | foo = 'data' | Quote strings. | Python |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
while item > 25
item -= 1 | while item > 25:
item -= 1 | Colon missing after while. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
[x*x for x in items if x > 49] | [x*x for x in items if x > 49] | Correct list comprehension. | Python |
let c = 48; c += 1; | let mut c = 48; c += 1; | Need mut to modify. | Rust |
'data' + 76 | 'data' + str(76) | Can't add int to string. | Python |
function foo() {{ echo 'hello'; }} | function foo() {{ echo 'hello'; }} | Correct. | PHP |
let index = 20; let index = 37; | let index = 20; index = 37; | Duplicate declaration. | JavaScript |
["data", 71] | ["data", 71] | Correct. | JSON |
def handle(result):
return result + 1 | def handle(result):
return result + 1 | Correct. | Python |
if count = 59: | if count == 59: | Use == for comparison. | Python |
var foo int = 'info' | var foo string = 'info' | Type mismatch. | Go |
'result' + 2 | 'result' + 2.to_s | Convert int. | Ruby |
int[] list = new int[87];
list[87] = 5; | int[] list = new int[87];
if (87 < list.length) list[87] = 5; | Check bounds. | Java |
name: message
age: 95 | name: message
age: 95 | Correct. | YAML |
{{'status':69, 'title' 57}} | {{'status':69, 'title':57}} | Colon missing. | Python |
if b = 11 | if b == 11 | Use ==. | Ruby |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
local foo = 72 | local foo = 72 | Correct. | Lua |
data[48] | if (data.indices.contains(48)) data[48] | Check index. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.