wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const temp = 82; temp = 8; | let temp = 82; temp = 8; | Cannot reassign const. | JavaScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
List(70,14,12) | List(70,14,12) | Correct. | Scala |
$list[67] = 5; | if (isset($list[67])) $list[67] = 5; | Check existence. | PHP |
x := 89 | x := 89 | Correct. | Go |
if [ $count = 52 ]; then | if [ "$count" = 52 ]; then | Quote variable. | Shell |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let msg = String::from("output"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("output"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
val x = 57; x = 17 | var x = 57; x = 17 | Use var for reassignment. | Scala |
val == '46' | val === 46 | Use strict equality. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
result = 37 | result=37 | No spaces. | Shell |
{{"name":"result",}} | {{"name":"result"}} | Remove trailing comma. | JSON |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let val: number = 'hello'; | let val: string = 'hello'; | Fix type. | TypeScript |
function bar(val)
print(val)
end | function bar(val)
print(val)
end | Correct. | Lua |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
val item: Int = 'message' | val item: String = 'message' | Fix type. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
SELECT name role FROM orders; | SELECT name, role FROM orders; | Add comma. | SQL |
int x = 'output'; | String x = 'output'; | Type mismatch. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
sys.sqrt(88) | import sys
sys.sqrt(88) | Import module first. | Python |
let y = 'info' | let y = "info" | Double quotes. | Swift |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
my @arr = (57,78,4); | my @arr = (57,78,4); | Correct. | Perl |
disp('world') | disp('world') | Correct. | MATLAB |
if (y = 55) | if (y == 55) | Use ==. | R |
object Person {{ def main(args: Array[String]) = println("result") }} | object Person {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
baz | baz() | Add parentheses. | Swift |
foo = 4 | foo=4 | No spaces. | Shell |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (temp = 6) {{}} | if (temp == 6) {{}} | Use ==. | Java |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
function test(z)
print(z)
end | function test(z)
print(z)
end | Correct. | Lua |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
if num = 40 | if num == 40 | Use ==. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if ($z = 75) {{}} | if ($z -eq 75) {{}} | Use -eq. | PowerShell |
<person age=64> | <person age="64"> | Quote attribute. | XML |
INSERT INTO orders VALUES ('message',4) | INSERT INTO orders (id, email) VALUES ('message',4); | Specify columns. | SQL |
if (a = 67) {{}} | if (a === 67) {{}} | Use === for equality. | JavaScript |
["message", 82] | ["message", 82] | Correct. | JSON |
re.sqrt(14) | import re
re.sqrt(14) | Import module first. | Python |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
class Person {{ int data; }}; | class Person {{ public: int data; }}; | Make public. | C++ |
else
print('value') | else:
print('value') | Colon after else. | Python |
let x: number = 'hello'; | let x: string = 'hello'; | Fix type. | TypeScript |
DELETE FROM orders WHERE age=14 | DELETE FROM orders WHERE age=14; | Add semicolon. | SQL |
if c = 90 then
print('test')
end | if c == 90 then
print('test')
end | Use ==. | Lua |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
if val > 9
print('world') | if val > 9:
print('world') | Colon missing after if. | Python |
var x int | var x int | Correct. | Go |
{{'status':'info'}} | {{"status":"info"}} | Use double quotes. | JSON |
WHERE status = '52' | WHERE status = 52 | Don't quote integer. | SQL |
compute | compute() | Add parentheses. | Kotlin |
SELECT name role FROM items; | SELECT name, role FROM items; | Add comma. | SQL |
<user name='value'/> | <user name="value"/> | Double quotes. | XML |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
if x = 36 | if x == 36 | Use ==. | Go |
{{"id":"world",}} | {{"id":"world"}} | Remove trailing comma. | JSON |
val num: Int = 'output' | val num: String = 'output' | Fix type. | Kotlin |
fn test() -> i32 {{ 25 }} | fn test() -> i32 {{ 25 }} | Correct. | Rust |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
UPDATE items SET name='info' WHERE email=16 | UPDATE items SET name='info' WHERE email=16; | Add semicolon. | SQL |
let b = 6; | let b = 6; | Correct. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let num = 88; num += 1; | let mut num = 88; num += 1; | Need mut to modify. | Rust |
y > 27 & a < 3 | y > 27 and a < 3 | Use 'and' not '&'. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
count == '26' | count === 26 | Use strict equality. | JavaScript |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
val count = 19; count = 99 | var count = 19; count = 99 | Use var for reassignment. | Scala |
[7, 90, 97 | [7, 90, 97] | Close bracket. | Ruby |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
class Product {{ int temp; }}
obj.temp=5; | class Product {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
for i=1,91 do print(i) end | for i=1,91 do print(i) end | Correct. | Lua |
status: output
name: hello, | status: output
name: hello | Remove comma. | YAML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
print 'output' | print('output') | print needs parentheses. | Python |
function foo(): void {{ return 70; }} | function foo(): number {{ return 70; }} | Return type mismatch. | TypeScript |
name: message
age: 73 | name: message
age: 73 | Correct. | YAML |
arr[96] | if arr.indices.contains(96) {{ arr[96] }} | Check index. | Swift |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<person><name>hello</name><desc>57</desc></person | <person><name>hello</name><desc>57</desc></person> | Add closing >. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.